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
sqlite3.OperationalError: database is locked #637
Comments
Is there any way I can reproduce this? |
I use this script for multi worker:
And this script is calling telethon client:
What I basically do is adding group messages to mysql db based on last inserted message id. |
Please format your comment better (use |
Okay well the problem is that you're using the same |
I see, is there a way i can check if a session is already used? |
Well you should know if you have a connected client on a certain file. |
Yes, but in my multi thread scenario i'm not sure how i can do it rather than send this as a parm when running executors. Let's suppose i have generated 10 session files, how can i check from TelethonSync if session1 is taken and just increment the suffix until I reach an available session file. |
That's not a problem related to the library, and you should ask somewhere else. |
Okay, I thought that there might be some available methods in the library. Thanks a lot! Wish you all the best. |
Hi, |
Disabling saving entities is generally not a good idea, since they are required for a lot of things. The library is not thread-safe. It's designed to work well in |
hello
version of telethon is 0.19.1.6 my code :
|
In my case, I have |
@andrei-zamfirescu Have you resolved the blocking issue? I'm also interested in this, since I have to stop the asynchronous call session and start it again, which comes with additional errors besides blocking, I would like to be able to reuse the session, would it be enough for me to create a copy of the session file with a different name? @Lonami Wouldn't it be easier to make it possible to use another database for the session store so that no locking occurs? |
Locking is a feature, not a bug. It prevents user errors. Under normal operation, this error does not occur. If you believe you're doing it correctly, and SQLite is giving you trouble, you're welcome to use a different storage. This is a supported and documented use-case. |
Yes, I understand what you mean, I just don't seem to understand possible mistakes, thank you for the quick response, I will try to describe what I'm doing: I have created a solution that starts several sessions at once in the same queue for executing asynchronous functions, they seem to work simultaneously and listen for events. Sometimes I need to change the settings, for this to get, for example, user chats, this is a separate request that requires connection through a session that has already taken sqlite, for this I have to send a shutdown of an asynchronous task that works in the background, it does not always work correctly, since knowledge in programming is weak, but I realized that I can for individual requests, for example, to get a list of chats, create a separate session with a different name, this will allow me to execute requests without blocking and stopping the main session. Perhaps there is a better way, I would be very grateful, thank you again. |
Hello,
Running telethon client with multi workers under pool executor causes constant database locks:
ERROR:telethon.telegram_bare_client:Connection was reset while receiving items. Reconnecting ERROR:telethon.telegram_bare_client:Connection was reset while receiving items. Reconnecting ERROR:telethon.telegram_bare_client:Unknown exception in the read thread! Disconnecting and leaving it to main t Traceback (most recent call last): File "/usr/local/lib/python3.4/dist-packages/telethon/telegram_bare_client.py", line 690, in _recv_thread_impl self.idle(stop_signals=tuple()) File "/usr/local/lib/python3.4/dist-packages/telethon/telegram_bare_client.py", line 659, in idle self._sender.receive(update_state=self.updates) File "/usr/local/lib/python3.4/dist-packages/telethon/network/mtproto_sender.py", line 147, in receive self._process_msg(remote_msg_id, remote_seq, reader, update_state) File "/usr/local/lib/python3.4/dist-packages/telethon/network/mtproto_sender.py", line 197, in _process_msg return self._handle_rpc_result(msg_id, sequence, reader) File "/usr/local/lib/python3.4/dist-packages/telethon/network/mtproto_sender.py", line 496, in _handle_rpc_res self.session.process_entities(request.result) File "/usr/local/lib/python3.4/dist-packages/telethon/session.py", line 405, in process_entities 'insert or replace into entities values (?,?,?,?,?)', rows sqlite3.OperationalError: database is locked
Is there a way we can fix this?
Thank you,
Andrei.
The text was updated successfully, but these errors were encountered: