Пример #1
0
    def handle(self):
        print('New connection from %s:%s' % self.client_address)
        msg = json.loads(netstring.read(self.request))
        with app.app_context():
            try:
                return self.handle_message(msg)
            except Exception as e:
                error_str = f'{type(e).__name__}: {e}'
                self.send_msg({'type': 'error', 'msg': error_str})

                info = 'matcher queue'
                mail.send_traceback(info, prefix='matcher queue')
Пример #2
0
    def run(self):
        with app.app_context():
            try:
                self.run_in_app_context()
            except Exception as e:
                error_str = f'{type(e).__name__}: {e}'
                self.send('error', msg=error_str)
                del active_jobs[(self.osm_type, self.osm_id)]

                info = 'matcher queue'
                mail.send_traceback(info, prefix='matcher queue')

        print('end thread:', self.name)
Пример #3
0
    def handle(self):
        print("New connection from %s:%s" % self.client_address)
        msg = chat.read_line(self.request)

        with app.app_context():
            try:
                return self.handle_message(msg)
            except Exception as e:
                error_str = f"{type(e).__name__}: {e}"
                self.send_msg({"type": "error", "msg": error_str})

                info = "matcher queue"
                mail.send_traceback(info, prefix="matcher queue")
Пример #4
0
    def run(self):
        with app.app_context():
            try:
                self.run_in_app_context()
            except Exception as e:
                error_str = f"{type(e).__name__}: {e}"
                print(error_str)
                self.send("error", msg=error_str)
                self.end_job()

                info = "matcher queue"
                mail.send_traceback(info, prefix="matcher queue")
                traceback.print_exc()

        print("end thread:", self.name)
Пример #5
0
def process_queue_loop():
    with app.app_context():
        while True:
            process_queue()
Пример #6
0
        for i in (candidates or []):
            c = ItemCandidate.query.get(
                (item.item_id, i['osm_id'], i['osm_type']))
            if not c:
                c = ItemCandidate(**i, item=item)
                database.session.add(c)
        print(len(candidates), item.label)
    place.state = 'ready'
    database.session.commit()

    conn.close()


def reindex_all(skip_places=None):
    q = Place.query.filter(Place.state.isnot(None), Place.state != 'ready')
    if skip_places:
        q = q.filter(~Place.osm_id.in_(skip_places))
    for place in q:
        do_reindex(place, force=True)


app.config.from_object('config.default')
with app.app_context():
    database.init_app(app)
    if len(sys.argv) > 1:
        place_id = sys.argv[1]
        place = Place.query.get(place_id)
        do_reindex(place, force=True)
    else:
        reindex_all()
Пример #7
0
    def run(self):
        with app.app_context():
            self.run_in_app_context()

        print('end thread:', self.name)