{"id":2087,"date":"2022-08-30T15:21:56","date_gmt":"2022-08-30T15:21:56","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2013\/12\/25\/problem-about-gevent-collection-of-common-programming-errors\/"},"modified":"2022-08-30T15:21:56","modified_gmt":"2022-08-30T15:21:56","slug":"problem-about-gevent-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2022\/08\/30\/problem-about-gevent-collection-of-common-programming-errors\/","title":{"rendered":"problem about gevent-Collection of common programming errors"},"content":{"rendered":"<ul>\n<li>\n<img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/2d675895c2aa907fc3356579b4e644b9?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\ntldr<br \/>\njavascript python node.js exception-handling gevent<br \/>\nSomeone at a meetup yesterday told me that if a callback throws an exception in Node.js, it will crash the entire process. But if a greenlet throws an uncaught exception in Gevent, it only crashes the greenlet. I don&#8217;t have experience with Gevent, and am wondering if that is true.<\/li>\n<li>\n<img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/04a81fb08429967b5a69e0e08b3872fe?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nIvan Kovacevic<br \/>\npython urllib2 gevent<br \/>\nI&#8217;m trying to build a proxy\/cache server for one location autocompletion api. Here is the simplified code that manifests the error almost all the time I try to query my server:#!\/usr\/bin\/python import gevent from gevent import monkey from gevent.wsgi import WSGIServer monkey.patch_all()import urllib2 import urlparse import jsondef requestHandler(env, start_response):start_response(&#8216;200 OK&#8217;, [(&#8216;Content-Type&#8217;, &#8216;text&#8217;)])parameters = urlparse.parse_qs(env[&#8216;QUERY_STRING&#8217;])if &#8216;search&#8217; in parameters:se<\/li>\n<li>\n<img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/1b9f56786ceba3c57d0d2fe56182a4d3?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nKate Gregory<br \/>\npython exception gevent<br \/>\ni&#8217;m working with an application written in python using gevent. i want it to exit immediately as a result of any exception that i haven&#8217;t explicitly trapped. it looks like i&#8217;d have to patch the core gevent code.is there any way can i do this in my app, without patching gevent or greenlet?<\/li>\n<li>\n<img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/0ef062b71557bbdb78bebf4cace629ce?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nChrome<br \/>\npython gevent<br \/>\nI have code:import gevent import gevent.monkey; gevent.monkey.patch_all() import requestsdef func():try:requests.get(&#8216;http:\/\/unavailable-host\/&#8217;)except:passdef main():jobs = [gevent.spawn(func) for i in xrange(10)]gevent.joinall(jobs)if __name__ == &#8216;__main__&#8217;:main()This script usually nothing output. But sometimes (in 1 of 5 runs) i get this message:Unhandled exception in thread started by sys.excepthook is missing lost sys.stderrExplain me, why this happen, and what is right solution? Also, if I<\/li>\n<li>\n<img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/bca6456c3a188b62783da4ac50396d06?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nMansour<br \/>\npython tornado gevent<br \/>\nWhen running tornado&#8217;s WSGIApplication through gevent&#8217;s pywsgi server, the exceptions in greenlets are suppressed and do not show up in the standard error\/output. I have looked and looked and couldn&#8217;t find why this is happening.Here&#8217;s a little test app to demonstrate:#!\/usr\/bin\/env pythonimport gevent.monkey gevent.monkey.patch_all()import gevent.wsgi import tornado.web import tornado.wsgiclass MainHandler(tornado.web.RequestHandler):def prepare(self):# this next line will cause a NameErrora = i<\/li>\n<li>\n<img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/b24cfa766bcbb21d3750def1365ab906?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nVimos<br \/>\npython gevent<br \/>\nWhen I run an example of gevent, I get import error here. I am using macos, gevent is installed by pip.Python 2.7.2 (default, Oct 11 2012, 20:14:37) [GCC 4.2.1 Compatible Apple Clang 4.0 (tags\/Apple\/clang-418.0.60)] on darwin Type &#8220;help&#8221;, &#8220;copyright&#8221;, &#8220;credits&#8221; or &#8220;license&#8221; for more information. &gt;&gt;&gt; import gevent &gt;&gt;&gt; from gevent import socket &gt;&gt;&gt; urls = [&#8216;www.google.com&#8217;, &#8216;www.example.com&#8217;, &#8216;www.python.org&#8217;] &gt;&gt;&gt; jobs = [gevent.spawn(socket.gethostbyname, url)<\/li>\n<li>\n<img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/f8c63410ad2ade1978775862befb95ff?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nunpluggd<br \/>\npython libevent gevent<br \/>\nI&#8217;m trying to install gevent on a fresh EC2 CentOS 5.3 64-bit system.Since the libevent version available in yum was too old for another package (beanstalkd) I compiled\/installed libevent-1.4.13-stable manually using the following command:.\/configure &#8211;prefix=\/usr &amp;&amp; make &amp;&amp; make installThis is the output from installing gevent:[gevent-0.12.2]# python setup.py build &#8211;libevent \/usr\/lib Using libevent 1.4.13-stable: libevent.so running build running build_py running build_ext Link<\/li>\n<li>\n<img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/d3bd7339e1941bc25c05110b69a82721?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nDanilo Bargen<br \/>\npython concurrency gevent<br \/>\nI&#8217;m doing a few dozen HTTP requests inside a Gevent pool.The goal is to retry a request once if it failed, but only once. Otherwise, it should throw an exception.How would I write gevent code with at pool that supports re-running HTTP requests once if they fail?Could this approach work?import requests import gevent from gevent.pool import Poolpool = Pool(10)def do_request(id):r = requests.get(&#8216;http:\/\/example.com\/%u&#8217; % id)if not r.status_code == 200:raise RuntimeError(id)def spawn_greenlet(id, is<\/li>\n<li>\n<img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/7743eab8a5fe5da8c3771f3de2fc8c42?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nMahmoud Abdelkader<br \/>\npython exception gevent gunicorn python-requests<br \/>\nFirst off, the versions:gevent &#8211; v0.13.7 gunicorn &#8211; v0.14.2 requests &#8211; 0.11.2We recently upgraded our servers that are running behind gunicorn to use the gevent asynchronous workers instead of just normal sync workers. Everything works great, but we&#8217;re now experiencing an issue when attempting to access a 3rd party service over http and I just have no idea how to track down what might be the issue.A brief stack trace looks like the following:File &#8220;\/home\/deploy\/.virtualenvs\/bapp\/lib\/python2.7\/s<\/li>\n<\/ul>\n<p id=\"rop\"><small>Originally posted 2013-12-25 10:55:40. <\/small><\/p>","protected":false},"excerpt":{"rendered":"<p>tldr javascript python node.js exception-handling gevent Someone at a meetup yesterday told me that if a callback throws an exception in Node.js, it will crash the entire process. But if a greenlet throws an uncaught exception in Gevent, it only crashes the greenlet. I don&#8217;t have experience with Gevent, and am wondering if that is [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-2087","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/2087","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=2087"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/2087\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=2087"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=2087"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=2087"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}