-
Notifications
You must be signed in to change notification settings - Fork 481
Telegram notifier bug, Instance ChatIdEntry is not bound to a Session #3108
Copy link
Copy link
Closed
Description
The first time to execute telegram notifier task, I got this exception:
sqlalchemy.orm.exc.DetachedInstanceError: Instance <ChatIdEntry at 0x2714f68ffa0> is not bound to a Session; attribute refresh operation cannot proceed (Background on this error at: http://sqlalche.me/e/14/bhk3)
It seems like a bug in the code components/notify/notifiers/telegram.py line 189:
def notify(self, title, message, config):
"""
Send a Telegram notification
"""
session = Session()
chat_ids = self._real_init(Session(), config)
if not chat_ids:
return
self._send_msgs(message, chat_ids, session)The temperary session Session() is passed to self._real_init, instead of the session variable. The exception disappers after the following modification.
def notify(self, title, message, config):
"""
Send a Telegram notification
"""
session = Session()
chat_ids = self._real_init(session, config)
if not chat_ids:
return
self._send_msgs(message, chat_ids, session)Log:
(click to expand)
File "c:\users\luyiming\miniconda3\envs\pt\lib\site-packages\flexget\components\notify\notification_framework.py", line 122, in send_notification
notifier_plugin.notify(
| -> <function TelegramNotifier.notify at 0x000002714BC7BD30>
-> <flexget.components.notify.notifiers.telegram.TelegramNotifier object at 0x000002714E03B430>
File "c:\users\luyiming\miniconda3\envs\pt\lib\site-packages\flexget\components\notify\notifiers\telegram.py", line 193, in notify
self._send_msgs(message, chat_ids, session)
| | | | -> <sqlalchemy.orm.session.ContextSession object at 0x000002714FAFFCA0>
| | | -> [<flexget.components.notify.notifiers.telegram.ChatIdEntry object at 0x000002714F68FFA0>]
| | -> 'Notification body.'
| -> <function TelegramNotifier._send_msgs at 0x000002714BC8A1F0>
-> <flexget.components.notify.notifiers.telegram.TelegramNotifier object at 0x000002714E03B430>
File "c:\users\luyiming\miniconda3\envs\pt\lib\site-packages\flexget\components\notify\notifiers\telegram.py", line 303, in _send_msgs
for chat_id in (x.id for x in chat_ids):
-> [<flexget.components.notify.notifiers.telegram.ChatIdEntry object at 0x000002714F68FFA0>]
File "c:\users\luyiming\miniconda3\envs\pt\lib\site-packages\flexget\components\notify\notifiers\telegram.py", line 303, in <genexpr>
for chat_id in (x.id for x in chat_ids):
| | -> <flexget.components.notify.notifiers.telegram.ChatIdEntry object at 0x000002714F68FFA0>
| -> <sqlalchemy.orm.attributes.InstrumentedAttribute object at 0x000002714A36E0E0>
-> <flexget.components.notify.notifiers.telegram.ChatIdEntry object at 0x000002714F68FFA0>
File "c:\users\luyiming\miniconda3\envs\pt\lib\site-packages\sqlalchemy\orm\attributes.py", line 480, in __get__
return self.impl.get(state, dict_)
| | | | -> {'_sa_instance_state': <sqlalchemy.orm.state.InstanceState object at 0x000002714F65EFD0>}
| | -> <function AttributeImpl.get at 0x0000027129FC80D0>
| -> <sqlalchemy.orm.attributes.ScalarAttributeImpl object at 0x0000027152189F70>
-> <sqlalchemy.orm.attributes.InstrumentedAttribute object at 0x000002714A36E0E0>
File "c:\users\luyiming\miniconda3\envs\pt\lib\site-packages\sqlalchemy\orm\attributes.py", line 926, in get
value = state._load_expired(state, passive)
| | | -> symbol('PASSIVE_OFF')
| | -> <sqlalchemy.orm.state.InstanceState object at 0x000002714F65EFD0>
| -> <function InstanceState._load_expired at 0x0000027129FE15E0>
-> <sqlalchemy.orm.state.InstanceState object at 0x000002714F65EFD0>
File "c:\users\luyiming\miniconda3\envs\pt\lib\site-packages\sqlalchemy\orm\state.py", line 710, in _load_expired
self.manager.expired_attribute_loader(self, toload, passive)
| | | | | -> symbol('PASSIVE_OFF')
| | | | -> {'id', 'surname', 'username', 'group', 'firstname'}
| | | -> <sqlalchemy.orm.state.InstanceState object at 0x000002714F65EFD0>
| | -> functools.partial(<function load_scalar_attributes at 0x000002712A02D1F0>, <Mapper at 0x2714bc7dbe0; ChatIdEntry>)
| -> <ClassManager of <class 'flexget.components.notify.notifiers.telegram.ChatIdEntry'> at 2714ba61310>
-> <sqlalchemy.orm.state.InstanceState object at 0x000002714F65EFD0>
File "c:\users\luyiming\miniconda3\envs\pt\lib\site-packages\sqlalchemy\orm\loading.py", line 1367, in load_scalar_attributes
raise orm_exc.DetachedInstanceError(
| -> <class 'sqlalchemy.orm.exc.DetachedInstanceError'>
-> <module 'sqlalchemy.orm.exc' from 'c:\\users\\luyiming\\miniconda3\\envs\\pt\\lib\\site-packages\\sqlalchemy\\orm\\exc.py'>
sqlalchemy.orm.exc.DetachedInstanceError: Instance <ChatIdEntry at 0x2714f68ffa0> is not bound to a Session; attribute refresh operation cannot proceed (Background on this error at: http://sqlalche.me/e/14/bhk3)
Additional information:
- FlexGet version: 3.1.133
- Python version: 3.8.10
- Installation method: pip
- Using daemon (yes/no): no
- OS and version: Windows 10
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels