Commit c006dde8 authored by Ondřej Kuzník's avatar Ondřej Kuzník
Browse files

Connection closing WIP

parent b7694b4a
......@@ -85,11 +85,12 @@ class AsyncClient(ldap.ldapobject.LDAPObject):
super().__init__(*args, **kwargs)
self._in_progress = {}
self._loop = loop or asyncio.get_event_loop()
self._have_reader = False
self._have_reader = None
def _shutdown(self):
self._loop.remove_reader(self)
self._have_reader = False
if self._have_reader is not None:
self._loop.remove_reader(self._have_reader)
self._have_reader = None
while self._in_progress:
try:
......@@ -154,9 +155,10 @@ class AsyncClient(ldap.ldapobject.LDAPObject):
request = LDAPRequest(self, msgid)
self._in_progress[msgid] = request
if not self._have_reader:
self._loop.add_reader(self, self._read)
self._have_reader = True
if self._have_reader is None:
fd = self.fileno()
self._loop.add_reader(fd, self._read)
self._have_reader = fd
return request
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment