Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- import os
- import time
- import threading
- from trytond.config import CONFIG
- config_file = os.environ.get('TRYTOND_CONF', '/etc/trytond.conf')
- CONFIG.update_etc(config_file)
- from trytond.backend import Database
- from trytond.pool import Pool
- threads = {}
- def run_cron():
- while True:
- try:
- db = Database().connect()
- cursor = db.cursor()
- db_list = db.list(cursor)
- for db_name in db_list:
- thread = threads.get(db_name)
- if thread and thread.is_alive():
- continue
- pool = Pool(db_name)
- pool.init(update=False, lang=None)
- Cron = pool.get('ir.cron')
- thread = threading.Thread(
- target=Cron.run,
- args=(db_name,), kwargs={})
- thread.start()
- threads[db_name] = thread
- finally:
- cursor.close(close=True)
- time.sleep(60)
- if __name__ == '__main__':
- run_cron()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement