-
Notifications
You must be signed in to change notification settings - Fork 255
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
Make sure that only one cursor possible per connection #24
Comments
Sure, by DB API spec there is the only cursor is allowed for connection object in the same time. |
Hello, I've been playing around with asyncio and used aiomysql for database access, I noticed that coroutines cannot create cursors from a shared connection (like the title of this issue states). |
It's by DB-API design, not specifically PyMYSQL. So yes, you should live with it. |
Sorry but I cannot find anything that says that, the only thing is this section in the DB API, but it does not mention that only one cursor per connection can exist at any time |
Well. It's not stated explicitly. But using non-isolated cursors is dangerous idea at first. |
Except for libraries with threadsafety 2 or 3 I guess? (I'm talking about threads here) Edit: I see now that PyMSQL has thread-safety level 1 |
I think it's orthogonal concept. So it's mostly server limitation, not client one. |
OK I see, thanks |
Should we just add a stub, with an exception if we call |
I think guard like following is enough. if self._guard:
raise OperationError("Connection cannot be used in parallel")
self._guard = True
await self._execute_command(...)
await self._read_ok_packet(...)
self._guard = False |
If I need to wait for 100 queries. Does this mean I need to call |
We allow multiple cursors per connection, I guess we need to forbid such behaviour and make sure only one cursor possible per connection. There is test that failing on multiple cursors https://github.com/aio-libs/aiomysql/blob/master/tests/test_nextset.py#L53-L73 , should be fixed too.
The text was updated successfully, but these errors were encountered: