-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AIOLDAPConnection has loop affinity #69
Comments
For the record, here is the code that I use to establish the connection.
|
[ EDIT: this does not work. See next comment. -gstein ] And how to actually use the connection, retaining its async properties. I've observed two connections using the same thread/loop, though the Executor will spin up a new thread if congestion occurs.
|
Actually, ignore that last comment. It does not properly steer the invocation back to the same thread/loop. The Executor may end up choosing a different thread, and things will break. Hard. ... |
My new/revised code pairs a bonsai LDAPConnection with an event loop. These loops can be used on any thread within the Executor. This ensures that an LDAPConnection continues to operate with its associated loop. |
I've been working on code to solve #25 and #41 by moving the
.connect()
into a separate thread via the Executor capabilities ofasyncio
. I've got this working, but have found the connection object holds onto the loop it was constructed with.What this means, is that I cannot construct the connection on a background thread/loop, and then use it on the main thread/loop going forwards. All future operations must go back to that original loop (running on a distinct thread, within an Executor).
To remedy this, I've set up a system where any operation request goes through the Executor, and gets passed over to the original thread and loop assigned to that thread. Not fun, but the main loop is never bothered while this stuff is threshing around. My test code shows a regular heartbeat on the primary event loop.
I really do not have a suggestion. This is some deep magic in the
AIOLDAPConnection
class, caused by its needs to manage file descriptors on the loop. I don't see an obvious fix; it feels like a deeper design decision. Sigh.The text was updated successfully, but these errors were encountered: