eventlet如何绿化pyserial最好

celery5.2.1以下版本任务调用多耗费1秒

妙音 posted @ 2021年12月28日 10:14 in python with tags celery , 345 阅读

问题

 
    5.0.5版本celery存在一个缺陷, 调用任务耗时多用1秒
 
    这个问题在5.2.0, 5.1.2同样存在
 
    没理解为什么到5.2.1版本才解决,甚至一度把celery排除python技术栈
 

环境描述

 
 
python3.6
celery5.0.5
windows 32位
 
 

调用celery任务代码摘要

 
# 1.send_task返回AsyncResult
# 2.AsyncResult的get()等待返回结果
# 3.get()会比真实多耗费1秒,并且每次请求都会出现

from celery import Celery
class xxxCelery(Celery):
    def call_xxx(self, name, timeout=120, **kwargs):
        LOG.info("send_task: %s" % locals())
        start = time.time()
        r = self.send_task(name, **kwargs)
        g = eventlet.spawn(r.get, timeout=timeout)
        result = g.wait()
        print("cost: %s" % time.time()-start)
        return
 

两个版本比对

 
分析celery源码之后,可以知道问题在drain_events()内部, 比较5.2.0和5.2.1版本
 
#celery/backends/asynchronuse.py

class greenletDrainer(Drainer):
    ...
    def run(self):
        self._started.set()
        while not self._stopped.is_set():
            try:
                self.result_consumer.drain_events(timeout=1)
                # 新增了两句, 估摸着是这个问题
                self._send_drain_complete_event()
                self._create_drain_complete_event()
            except socket.timeout:
                pass
        self._shutdown.set()
 
 

解决办法

 
    celery升级到5.2.1
 
    python要升级到3.7以上版本(celery要求python3.7以上版本)
 

解决效果

 
    耗时从1000多ms变成了30ms
 
Avatar_small
Digital_Zone 说:
2021年12月29日 03:47 A very excellent blog post. I am thankful for your blog post. I have found a lot of approaches after visiting your post. minecraft servers
Avatar_small
Denise Caroll 说:
2022年1月02日 17:28 Yes i am totally agreed with this article and i just want say that this article is very nice and very informative article.I will make sure to be reading your blog more. You made a good point but I can't help but wonder, what about the other side? !!!!!!Thanks CableGallagher
Avatar_small
Denise Caroll 说:
2022年1月02日 17:31

Wow! Such an amazing and helpful post this is. I really really love it. It's so good and so awesome. I am just amazed. I hope that you continue to do your work like this in the future also Refurbished Home

Avatar_small
Denise Caroll 说:
2022年1月02日 17:33

Hello I am so delighted I located your blog, I really located you by mistake, while I was watching on google for something else, Anyways I am here now and could just like to say thank for a tremendous post and a all round entertaining website. Please do keep up the great work. FunkyAndCreative

Avatar_small
Denise Caroll 说:
2022年1月02日 17:36

I was surfing the Internet for information and came across your blog. I am impressed by the information you have on this blog. It shows how well you understand this subject. Librarian Chic

Avatar_small
Denise Caroll 说:
2022年1月02日 17:39

Wow, What a Excellent post. I really found this to much informatics. It is what i was searching for.I would like to suggest you that please keep sharing such type of info.Thanks https://www.eulis.org/

Avatar_small
Denise Caroll 说:
2022年1月02日 17:42

This is such a great resource that you are providing and you give it away for free. I love seeing blog that understand the value of providing a quality resource for free. ZeztaInternational

Avatar_small
Denise Caroll 说:
2022年1月02日 17:47

Positive site, where did u come up with the information on this posting? I'm pleased I discovered it though, ill be checking back soon to find out what additional posts you include. SomewhereElse

Avatar_small
Denise Caroll 说:
2022年1月02日 17:52

This is my first time i visit here. I found so many interesting stuff in your blog especially its discussion. From the tons of comments on your articles, I guess I am not the only one having all the enjoyment here keep up the good work TheBatwatrail

Avatar_small
Denise Caroll 说:
2022年1月02日 17:55

Positive site, where did u come up with the information on this posting?I have read a few of the articles on your website now, and I really like your style. Thanks a million and please keep up the effective work. https://www.gtwn.net/

Avatar_small
Denise Caroll 说:
2022年1月02日 17:58

Thanks for a very interesting blog. What else may I get that kind of info written in such a perfect approach? I’ve a undertaking that I am simply now operating on, and I have been at the look out for such info. Digg and Dot blog

Avatar_small
Denise Caroll 说:
2022年1月02日 18:00

nice post, keep up with this interesting work. It really is good to know that this topic is being covered also on this web site so cheers for taking time to discuss this! https://www.velocirepraptor.com/

Avatar_small
Denise Caroll 说:
2022年1月02日 18:04

Impressive web site, Distinguished feedback that I can tackle. Im moving forward and may apply to my current job as a pet sitter, which is very enjoyable, but I need to additional expand. Regards. RJCity

Avatar_small
Denise Caroll 说:
2022年1月02日 18:07

I think this is one of the most significant information for me. And i’m glad reading your article. But should remark on some general things, The web site style is perfect, the articles is really great : D. Good job, cheers WorldFitnessCR

Avatar_small
Denise Caroll 说:
2022年1月02日 18:09

I am unable to read articles online very often, but I’m glad I did today. This is very well written and your points are well-expressed. Please, don’t ever stop writing. MeMagazineBlog

Avatar_small
Denise Caroll 说:
2022年1月02日 18:12

Someone Sometimes with visits your blog regularly and recommended it in my experience to read as well. The way of writing is excellent and also the content is top-notch. Thanks for that insight you provide the readers! EverTravel

Avatar_small
Denise Caroll 说:
2022年1月02日 18:14

I can’t imagine focusing long enough to research; much less write this kind of article. You’ve outdone yourself with this material. This is great content. OpenWorldBlog

Avatar_small
Denise Caroll 说:
2022年1月02日 18:16

Pretty nice post. I just stumbled upon your weblog and wanted to say that I have really enjoyed browsing your blog posts. After all I’ll be subscribing to your feed and I hope you write again soon! 100XCD

Avatar_small
Denise Caroll 说:
2022年1月02日 18:19

An interesting dialogue is price comment. I feel that it is best to write more on this matter, it may not be a taboo topic however usually individuals are not enough to talk on such topics. To the next. Cheers. ThinkNOO

Avatar_small
Denise Caroll 说:
2022年1月02日 18:22

You have done a great job on this article. It’s very readable and highly intelligent. You have even managed to make it understandable and easy to read. You have some real writing talent. Thank you. TedXAshokau

Avatar_small
Denise Caroll 说:
2022年1月02日 18:25

That is the excellent mindset, nonetheless is just not help to make every sence whatsoever preaching about that mather. Virtually any method many thanks in addition to i had endeavor to promote your own article in to delicius nevertheless it is apparently a dilemma using your information sites can you please recheck the idea. thanks once more. https://www.g2cs.org/

Avatar_small
Denise Caroll 说:
2022年1月02日 18:27

Thank you so much as you have been willing to share information with us. We will forever admire all you have done here because you have made my work as easy as ABC. VisionSheen

Avatar_small
Denise Caroll 说:
2022年1月03日 05:10

Why do only so much written on this subject? Here you see more. blowjob

Avatar_small
Digital_Zone 说:
2022年1月06日 07:05 Good website! I truly love how it is easy on my eyes it is. I am wondering how I might be notified whenever a new post has been made. I have subscribed to your RSS which may do the trick? Have a great day! Escort in Karachi
Avatar_small
Digital_Zone 说:
2022年1月06日 07:10

Thank you a bunch for sharing this with all of us you actually realize what you are talking about! Bookmarked. Please also seek advice from my site =). We could have a hyperlink change contract between us! Call Girls in Islamabad

Avatar_small
Digital_Zone 说:
2022年1月06日 07:13

Without fail, your writing style is top professional; even your website also looks amazing thank you for posting. Escorts in Karachi

Avatar_small
Digital_Zone 说:
2022年1月06日 07:16

Thank you so much as you have been willing to share information with us. We will forever admire all you have done here because you have made my work as easy as ABC. Call Girls in Karachi

Avatar_small
Digital_Zone 说:
2022年1月06日 07:18

Succeed! It could be one of the most useful blogs we have ever come across on the subject. Excellent info! I’m also an expert in this topic so I can understand your effort very well. Thanks for the huge help. Karachi Escorts

Avatar_small
Digital_Zone 说:
2022年1月06日 07:21

Efficiently written information. It will be profitable to anybody who utilizes it, counting me. Keep up the good work. For certain I will review out more posts day in and day out. Lahore Call Girls

Avatar_small
Digital_Zone 说:
2022年1月06日 07:24

Your content is nothing short of bright in many forms. I think this is friendly and eye-opening material. I have gotten so many ideas from your blog. Thank you so much. Call Girls in Lahore

Avatar_small
Digital_Zone 说:
2022年1月06日 07:26

Hi, I find reading this article a joy. It is extremely helpful and interesting and very much looking forward to reading more of your work.. Escorts in Lahore

Avatar_small
Digital_Zone 说:
2022年1月06日 07:28

I visit your blog regularly and recommend it to all of those who wanted to enhance their knowledge with ease. The style of writing is excellent and also the content is top-notch. Thanks for that shrewdness you provide the readers! Lahore Escorts

Avatar_small
Digital_Zone 说:
2022年1月06日 07:31

This is such a great resource that you are providing and you give it away for free. I love seeing blog that understand the value of providing a quality resource for free. Lahore Escort Service

Avatar_small
Digital_Zone 说:
2022年1月06日 07:33

I can’t believe focusing long enough to research; much less write this kind of article. You’ve outdone yourself with this material without a doubt. It is one of the greatest contents. Islamabad Escort

Avatar_small
Digital_Zone 说:
2022年1月06日 07:36

Thanks for your insight for your fantastic posting. I’m exhilarated I have taken the time to see this. It is not enough; I will visit your site every day. Call girls in Islamabad

Avatar_small
Digital_Zone 说:
2022年1月06日 07:39

Thanks for picking out the time to discuss this, I feel great about it and love studying more on this topic. It is extremely helpful for me. Thanks for such a valuable help again. Luxury Islamabad Girls

Avatar_small
Digital_Zone 说:
2022年1月06日 07:42

You have a real talent for writing unique content. I like how you think and the way you express your views in this article. I am impressed by your writing style a lot. Thanks for making my experience more beautiful. Islamabad Call Girls

Avatar_small
Digital_Zone 说:
2022年1月06日 07:44

Pretty nice post. I just stumbled upon your weblog and wanted to say that I have really enjoyed browsing your blog posts. After all I’ll be subscribing to your feed and I hope you write again soon! Escorts In Islamabad

Avatar_small
Digital_Zone 说:
2022年1月06日 07:47

It is truly a well-researched content and excellent wording. I got so engaged in this material that I couldn’t wait reading. I am impressed with your work and skill. Thanks. Pakistan Escorts

Avatar_small
Digital_Zone 说:
2022年1月06日 07:49

I am impressed. I don't think Ive met anyone who knows as much about this subject as you do. You are truly well informed and very intelligent. You wrote something that people could understand and made the subject intriguing for everyone. Really, great blog you have got here. Pakistani Call Girls

Avatar_small
baba 说:
2022年1月07日 14:17

Nice post! This is a very nice blog that I will definitively come back to more times this year! Thanks for informative post. building 900-biscayne For Sale

Avatar_small
satta 说:
2022年1月27日 17:58

I am very enjoyed for this blog. Its an informative topic. It help me very much to solve some problems. Its opportunity are so fantastic and working style so speedy.


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter