Delay global_connection and global_transaction initialization to latest possible moment#158
Delay global_connection and global_transaction initialization to latest possible moment#158gvbgduh merged 2 commits intoencode:masterfrom
Conversation
82a57c8 to
190b8e3
Compare
|
Seems reasonable yup - what's the behavior of the test case without this change? |
|
@tomchristie if you were to merge only tests part of this PR, then test case would reproduce my initial issue, and tests would fail with |
|
Looks all v sensible to me. |
|
Looks safe to merge anyway! But for future we can revise the |
This reverts commit c18b19c.
This PR changes
Databaseimplementation so global connection is created only when its actually needed: when connection with backend is initialized. That way connection and its locks are initialized within same event loop, preventing issue documented in #157.I've also had to change async_adapter implementation so it creates new event loop on every use instead of reusing already-existing event loop, which allowed me to reproduce error described in #157. It should also make tests run in env closer to "real" usage.