29d4c8008bf062f0e90b0c0653907bed2ee3d48b,src/syft/core/node/domain/service/request_handler_service.py,UpdateRequestHandlerService,process,#Any#Any#Any#,279

Before Change


            if existing_handlers is not None:
                for existing_handler in existing_handlers:
                    keys = set(existing_handler.keys())
                    keys.remove("created_time")  // the new handler has none
                    values = [existing_handler[key] for key in keys]
                    if keys == new_keys and set(new_values) == set(values):
                        // if keep is True we will add a new one

After Change


            existing_handlers = getattr(node, "request_handlers", None)
            debug(f"> Updating Request Handlers with existing: {existing_handlers}")
            if existing_handlers is not None:
                matched = None
                for existing_handler in existing_handlers:
                    // we match two handlers according to their tags
                    if existing_handler["tags"] == msg.handler["tags"]:
                        matched = existing_handler
                        // if an existing_handler match the passed in handler,
                        // we ignore it in for loop
                        continue
                    else:
                        // if an existing_handler does not match the passed in
                        // handler, we keep it
                        replacement_handlers.append(existing_handler)

                if msg.keep:
                    msg.handler["created_time"] = time.time()
                    replacement_handlers.append(msg.handler)
                    if matched is not None:
                        debug(
                            f"> Replacing a Request Handler {matched} with: {msg.handler}"
                        )
                    else:
                        debug(f"> Adding a Request Handler {msg.handler}")
                else:
                    debug(f"> Removing a Request Handler with: {msg.handler}")

                setattr(node, "request_handlers", replacement_handlers)
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 3

Instances


Project Name: OpenMined/PySyft
Commit Name: 29d4c8008bf062f0e90b0c0653907bed2ee3d48b
Time: 2021-02-02
Author: xvtongye1986@163.com
File Name: src/syft/core/node/domain/service/request_handler_service.py
Class Name: UpdateRequestHandlerService
Method Name: process


Project Name: keras-team/autokeras
Commit Name: 93fa8b46d0f38fa7035e8a2c1fd628359fe62433
Time: 2018-08-20
Author: jhfjhfj1@gmail.com
File Name: tests/common.py
Class Name:
Method Name: clean_dir


Project Name: deepmipt/DeepPavlov
Commit Name: 7d7c9cfcb200722f256f67337a6a6a827e7b4540
Time: 2019-08-08
Author: ignatov.fedor@gmail.com
File Name: deeppavlov/utils/socket/socket.py
Class Name: SocketServer
Method Name: __init__