MCPcopy Create free account
hub / github.com/TheSmallHanCat/flow2api / patched_send

Function patched_send

src/services/browser_captcha_personal.py:902–928  ·  view source on GitHub ↗
(self, cdp_obj, _is_update=False)

Source from the content-addressed store, hash-verified

900 self._future.cancel()
901
902 async def patched_send(self, cdp_obj, _is_update=False):
903 if _is_nodriver_connection_closed(self):
904 await self.connect()
905 if not _is_update:
906 await self._register_handlers()
907
908 tx_id = next(self.__count__)
909 try:
910 transaction = nodriver_connection_module.Transaction(cdp_obj)
911 transaction.id = tx_id
912 except Exception:
913 transaction = _CompatTransaction(cdp_obj, tx_id)
914 self.mapper[tx_id] = transaction
915
916 websocket = getattr(self, "websocket", None)
917 if websocket is None:
918 self.mapper.pop(tx_id, None)
919 if not transaction.done():
920 transaction.cancel()
921 raise ConnectionError("nodriver websocket unavailable after connect")
922
923 send_task = asyncio.create_task(websocket.send(transaction.message))
924 send_task.add_done_callback(
925 lambda task, connection=self, tx=transaction, current_tx_id=tx_id:
926 _finalize_nodriver_send_task(connection, tx, current_tx_id, task)
927 )
928 return await transaction
929
930 connection_instance.send = types.MethodType(patched_send, connection_instance)
931 connection_instance._flow2api_send_patched = True

Callers

nothing calls this directly

Calls 9

_CompatTransactionClass · 0.85
_register_handlersMethod · 0.80
doneMethod · 0.80
cancelMethod · 0.80
create_taskMethod · 0.80
connectMethod · 0.45
sendMethod · 0.45

Tested by

no test coverage detected