Skip to content
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

[BUG] PTBSQLAlchemyJobStore can't handle conversation timeout jobs #35

Open
l0rem opened this issue Nov 11, 2021 · 1 comment
Open

[BUG] PTBSQLAlchemyJobStore can't handle conversation timeout jobs #35

l0rem opened this issue Nov 11, 2021 · 1 comment
Labels
bug 🐛 Something isn't working

Comments

@l0rem
Copy link

l0rem commented Nov 11, 2021

Module in question: ptb_sqlalchemy_jobstore

Steps to reproduce

  1. Create a ConversationHandler with conversation_timeout set to any supported value other than None.

  2. Add PTBSQLAlchemyJobStore to dispatcher.job_queue.scheduler .

  3. Start the bot.

  4. Enter ConversationHandler created in step 1.

Expected behaviour

Conversation Timeout job should be added to job store.

Actual behaviour

Job cannot be stored due to serialisation error.

Configuration

MacOs 12.0.1, python 3.9.7

Version of Python, python-telegram-bot & dependencies:

python-telegram-bot 13.8.1
Bot API 5.4
certifi 2021.10.08
Python 3.9.7 (default, Oct 22 2021, 13:39:39)  [Clang 13.0.0 (clang-1300.0.29.3)]
ptbcontrib 0.0.0

Logs

Traceback (most recent call last):
  File "venv/lib/python3.9/site-packages/telegram/ext/conversationhandler.py", line 497, in _schedule_job
    self.timeout_jobs[conversation_key] = j_queue.run_once(  # type: ignore[union-attr]
  File "venv/lib/python3.9/site-packages/telegram/ext/jobqueue.py", line 196, in run_once
    j = self.scheduler.add_job(
  File "venv/lib/python3.9/site-packages/apscheduler/schedulers/base.py", line 444, in add_job
    self._real_add_job(job, jobstore, replace_existing)
  File "venv/lib/python3.9/site-packages/apscheduler/schedulers/base.py", line 868, in _real_add_job
    store.add_job(job)
  File "venv/lib/python3.9/site-packages/ptbcontrib-0.0.0-py3.9.egg/ptbcontrib/ptb_sqlalchemy_jobstore/jobstore.py", line 65, in add_job
    super().add_job(job)
  File "venv/lib/python3.9/site-packages/apscheduler/jobstores/sqlalchemy.py", line 95, in add_job
    'job_state': pickle.dumps(job.__getstate__(), self.pickle_protocol)
TypeError: cannot pickle '_thread.lock' object
2021-11-11 23:15:26,089 - cannot pickle '_thread.lock' object
Traceback (most recent call last):
  File "venv/lib/python3.9/site-packages/telegram/ext/conversationhandler.py", line 497, in _schedule_job
    self.timeout_jobs[conversation_key] = j_queue.run_once(  # type: ignore[union-attr]
  File "venv/lib/python3.9/site-packages/telegram/ext/jobqueue.py", line 196, in run_once
    j = self.scheduler.add_job(
  File "venv/lib/python3.9/site-packages/apscheduler/schedulers/base.py", line 444, in add_job
    self._real_add_job(job, jobstore, replace_existing)
  File "venv/lib/python3.9/site-packages/apscheduler/schedulers/base.py", line 868, in _real_add_job
    store.add_job(job)
  File "venv/lib/python3.9/site-packages/ptbcontrib-0.0.0-py3.9.egg/ptbcontrib/ptb_sqlalchemy_jobstore/jobstore.py", line 65, in add_job
    super().add_job(job)
  File "venv/lib/python3.9/site-packages/apscheduler/jobstores/sqlalchemy.py", line 95, in add_job
    'job_state': pickle.dumps(job.__getstate__(), self.pickle_protocol)
TypeError: cannot pickle '_thread.lock' object
@l0rem l0rem added the bug 🐛 Something isn't working label Nov 11, 2021
@l0rem
Copy link
Author

l0rem commented Nov 11, 2021

I forgot to mention, that jobs created with run_once (for example) are being stored and executed as expected, so i assume this is either undocumented limitation or a bug and not my error.

@l0rem l0rem closed this as completed Nov 11, 2021
@l0rem l0rem reopened this Nov 11, 2021
@Bibo-Joshi Bibo-Joshi changed the title [BUG] [BUG] PTBSQLAlchemyJobStore can't handle conversation timeout jobs Oct 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant