MCPcopy Create free account
hub / github.com/ActiveState/code / asyncAccept

Method asyncAccept

recipes/Python/577662_ASIO/recipe-577662.py:98–121  ·  view source on GitHub ↗
(self, callback)

Source from the content-addressed store, hash-verified

96 functools.partial(callback, err = err))
97
98 def asyncAccept(self, callback):
99 if (self.__acceptCallback):
100 raise AsyncException('Accept already in progress')
101 if (self.__connectCallback):
102 raise AsyncException('Connect already in progress')
103 if (self.__readCallback):
104 raise AsyncException('Read already in progress')
105 if (self.__writeAllCallback):
106 raise AsyncException('Write all already in progress')
107 if (self.__closed):
108 raise AsyncException('AsyncSocket closed')
109
110 try:
111 (newSocket, addr) = self.__socket.accept()
112 asyncSocket = AsyncSocket(self.__asyncIOService, newSocket)
113 self.__asyncIOService.invokeLater(
114 functools.partial(callback, sock = asyncSocket, err = 0))
115 except socket.error as e:
116 if e.args[0] in (errno.EAGAIN, errno.EWOULDBLOCK):
117 self.__acceptCallback = callback
118 self.__asyncIOService.registerAsyncSocketForRead(self)
119 else:
120 self.__asyncIOService.invokeLater(
121 functools.partial(callback, sock = None, err = e.args[0]))
122
123 def asyncRead(self, maxBytes, callback):
124 if (self.__acceptCallback):

Callers 2

__init__Method · 0.80
__acceptCallbackMethod · 0.80

Calls 5

AsyncExceptionClass · 0.85
AsyncSocketClass · 0.85
invokeLaterMethod · 0.80
acceptMethod · 0.45

Tested by

no test coverage detected