草庐IT

send_task

全部标签

python - 什么可以使 connection.send() 阻塞? (来自 conn1、conn2 = multiprocessing.Pipe() )

我正在调试从2个传感器收集信息的应用程序:一个网络摄像头和一个麦克风。总体架构非常简单:主进程通过管道向子进程(每个子进程一个)发送消息(开始、停止、get_data)。子进程收集数据并将其发送给主进程子进程和主进程无限循环处理命令(主进程来自用户,子进程来自主进程)。它在全局范围内有效,但我无法停止子进程。我已经记录了代码,它似乎发生了两件事:“停止”消息已发送但未通过管道。子进程继续发送数据和conn.send(data)block。此行为显然与连接状态有关,因为不发送任何内容的子进程没有此行为。尽管如此,我还是看不出如何调试/修改似乎合理的当前架构。那么,是什么导致了这种阻​​塞

python - 属性错误 : 'Client' object has no attribute 'send_message' (Discord Bot)

出于某种原因,send_message在我的Discord机器人上无法正常工作,而且我无法找到修复它的方法。importasyncioimportdiscordclient=discord.Client()@client.async_eventasyncdefon_message(message):author=message.authorifmessage.content.startswith('!test'):print('on_message!test')awaittest(author,message)asyncdeftest(author,message):print('in

python - 从未知任务中检索 Celery 中 'task_id' 的结果

如果我之前不知道执行了哪个任务,如何提取任务的结果?这是设置:给定以下来源('tasks.py'):fromceleryimportCeleryapp=Celery('tasks',backend="db+mysql://u:p@localhost/db",broker='amqp://guest:guest@localhost:5672//')@app.taskdefadd(x,y):returnx+y@app.taskdefmul(x,y):returnx*y在本地运行RabbitMQ3.3.2:marcs-mbp:sbinmarcstreeter$./rabbitmq-serve

python - 如何在 Flask send_file() 或 send_from_directory() 之后运行代码

我有一个基于Flask的网站,用户可以在其中下载一些PDF文件。使用Flask的send_file()很容易实现和send_from_directory().例如:@app.route('/downloadreport')defdownload_report():returnsend_from_directory('/reports','my_report.pdf',as_attachment=True)我想执行一些逻辑(我们称它为after_download())下载完成后。我试过使用@after_this_request钩。但看起来send_file()是异步运行的,所以@afte

Python 调用 - 找不到任何名为 'tasks' 的集合!

我做了入门PythonInvokefrominvokeimporttask@taskdefbuild():print("Building!")预期的输出是$invokebuildBuilding!但是,我的输出是$invokebuildCan'tfindanycollectionnamed'tasks'!我不知道为什么。令人惊奇的是,一旦我在virtualenv中调用,我就可以在没有virtualenv的情况下构建。>mkvirtualenvmyenv>invokebuildBuilding!>deactivatemyenv>invokebuildBuilding!我错过了什么吗?

python - 属性错误 : module 'asyncio' has no attribute 'create_task'

我正在尝试asyncio.create_task()但我正在处理这个错误:这是一个例子:importasyncioimporttimeasyncdefasync_say(delay,msg):awaitasyncio.sleep(delay)print(msg)asyncdefmain():task1=asyncio.create_task(async_say(4,'hello'))task2=asyncio.create_task(async_say(6,'world'))print(f"startedat{time.strftime('%X')}")awaittask1awaitt

python - 为什么我在 Python asyncio 中收到 "Task was destroyed but it is pending"错误?

我使用asyncio和漂亮的aiohttp。主要思想是我向服务器发出请求(它返回链接)然后我想从所有链接下载文件parallel(类似于example)。代码:importaiohttpimportasyncio@asyncio.coroutinedefdownloader(file):print('Download',file['title'])yieldfromasyncio.sleep(1.0)#someactionstodownloadprint('OK',file['title'])defrun():r=yieldfromaiohttp.request('get','my_u

python - 删除 celery 中的 Task/PeriodicTask

如何删除celery中的常规Task或PeriodicTask? 最佳答案 您撤销任务:参见documentation:Control.revoke(task_id,destination=None,terminate=False,signal='SIGTERM',**kwargs)Tellall(orspecific)workerstorevokeataskbyid.Ifataskisrevoked,theworkerswillignorethetaskandnotexecuteitafterall.Parameters:task

Python 套接字服务器 : sending to multiple clients?

好吧,我正在尝试构建一个带有SocketServer的小型python程序,它应该将它接收到的消息发送到所有连接的客户端。我被卡住了,我不知道如何在服务器端存储客户端,也不知道如何发送给多个客户端。哦,每次超过1个客户端连接时我的程序都会失败,每次客户端发送超过一条消息时...到目前为止,这是我的代码:printstr(self.client_address[0])+'connected.'defhandle(self):new=1forclientinclients:ifclient==self.request:new=0ifnew==1:clients.append(self.re

python - 使用 add_periodic_task 在 Celery (celerybeat) 中动态设置周期性任务

我正在使用Celery4.0.1和Django1.10并且我在安排任务时遇到了问题(运行任务正常)。这是celery配置:os.environ.setdefault('DJANGO_SETTINGS_MODULE','myapp.settings')app=Celery('myapp')app.autodiscover_tasks(lambda:settings.INSTALLED_APPS)app.conf.BROKER_URL='amqp://{}:{}@{}'.format(settings.AMQP_USER,settings.AMQP_PASSWORD,settings.AM