Tag: 后台进程

无限地在后台运行Python脚本

我正在尝试编写一个在另一个服务器上运行的python脚本,即使我在我的PCterminal上closures了我的服务器连接,它也会继续在该服务器上运行。当脚本保持活动状态时,它会无限次地运行网站(UI),事件发生后,它会适当地启动某些泊坞窗并继续收听PosgreSQL事件。 当我尝试使用nohup (在后台运行脚本)时,它在后台运行,但无法收听任何事件。 有没有人从事过类似的事情? 请分享你的想法。 我正在分享我的脚本的一部分。 self.pool = await asyncpg.create_pool(user='alg_user',password='algy',database='alg',host='brain',port=6543) async with self.pool.acquire() as conn: def enqueue_listener(*args): self.queue.put_nowait(args) await conn.add_listener('task_created', enqueue_listener) print("Added the listener") while True: print("—- Listening for new job —-") conn2, pid, channel, payload = await self.queue.get() x = re.sub("[^\w]", " ", payload).split() print(x) if x[5] == '1': tsk = 'TASK_ID=%s' % str(x[1]) […]