Exemplo n.º 1
0
 def start(self):
     # this is pretty unfortunate, but we have to reset the adapter
     # cache _before_ we fork on posix. libpq, but also any other
     # adapters that rely on file descriptors, get really messed up if
     # you fork(), because the fds get inherited but the state isn't
     # shared. The child process and the parent might end up trying to
     # do things on the same fd at the same time.
     # Also for some reason, if you do this after forking, even without
     # calling close(), the connection in the parent ends up throwing
     # 'connection already closed' exceptions
     cleanup_connections()
     self.process.start()
     self.state = TaskHandlerState.Running
     super().start()
Exemplo n.º 2
0
def adapter_management():
    reset_adapters()
    try:
        yield
    finally:
        cleanup_connections()