Created
January 15, 2024 06:31
-
-
Save alksndrglk/c29056a5f0651fd562feef7fe3c05aae to your computer and use it in GitHub Desktop.
session in thread
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| transmission = sessionmaker(db_transmission1c) | |
| class Handler(Thread): | |
| def __init__(self, q): | |
| Thread.__init__(self) | |
| self.q: Queue = q | |
| def run(self): | |
| def process(session): | |
| '''some important work''' | |
| while self.q.not_empty: | |
| content_id = self.q.get() | |
| try: | |
| with transmission.begin() as sessio: | |
| process(session) | |
| except (OperationalError, DatabaseError): | |
| logger.critical('UNDEFINED ERR: ', exc_info=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment