(self, callback)
| 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): |
no test coverage detected