(args, q)
| 838 | |
| 839 | |
| 840 | def db_updater(args, q): |
| 841 | # The forever loop |
| 842 | while True: |
| 843 | try: |
| 844 | |
| 845 | while True: |
| 846 | try: |
| 847 | flaskDb.connect_db() |
| 848 | break |
| 849 | except Exception as e: |
| 850 | log.warning('%s... Retrying', e) |
| 851 | |
| 852 | # Loop the queue |
| 853 | while True: |
| 854 | model, data = q.get() |
| 855 | bulk_upsert(model, data) |
| 856 | q.task_done() |
| 857 | log.debug('Upserted to %s, %d records (upsert queue remaining: %d)', |
| 858 | model.__name__, |
| 859 | len(data), |
| 860 | q.qsize()) |
| 861 | if q.qsize() > 50: |
| 862 | log.warning("DB queue is > 50 (@%d); try increasing --db-threads", q.qsize()) |
| 863 | |
| 864 | except Exception as e: |
| 865 | log.exception('Exception in db_updater: %s', e) |
| 866 | |
| 867 | |
| 868 | def clean_db_loop(args): |
nothing calls this directly
no test coverage detected