Commits

Denis Bilenko committed 2346922

examples: follow pep8

  • Participants
  • Parent commits f362ddf

Comments (0)

Files changed (7)

examples/concurrent_download.py

 
 import urllib2
 
+
 def print_head(url):
     print 'Starting %s' % url
     data = urllib2.urlopen(url).read()
 jobs = [gevent.spawn(print_head, url) for url in urls]
 
 gevent.joinall(jobs)
-

examples/dns_mass_resolve.py

 from gevent.pool import Pool
 
 N = 1000
-
 # limit ourselves to max 10 simultaneous outstanding requests
 pool = Pool(10)
+finished = 0
 
-finished = 0
 
 def job(url):
     global finished

examples/httpserver.py

 """
 from gevent import http
 
+
 def callback(request):
     print request
     if request.uri == '/':

examples/processes.py

 import subprocess
 import errno
 import sys
-import fcntl, os
+import os
+import fcntl
 
 
 def popen_communicate(args, data=''):
     """Communicate with the process non-blockingly."""
     p = subprocess.Popen(args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
-    fcntl.fcntl(p.stdin, fcntl.F_SETFL, os.O_NONBLOCK) # make the file nonblocking
-    fcntl.fcntl(p.stdout, fcntl.F_SETFL, os.O_NONBLOCK) # make the file nonblocking
+    fcntl.fcntl(p.stdin, fcntl.F_SETFL, os.O_NONBLOCK)  # make the file nonblocking
+    fcntl.fcntl(p.stdout, fcntl.F_SETFL, os.O_NONBLOCK)  # make the file nonblocking
 
     bytes_total = len(data)
     bytes_written = 0

examples/webpy.py

 #!/usr/bin/python
-
 """A web.py application powered by gevent"""
 
 from gevent import monkey; monkey.patch_all()
 urls = ("/", "index",
         '/long', 'long_polling')
 
+
 class index:
     def GET(self):
         return 'Hello, world!<br><a href="/long">/long</a>'
 
+
 class long_polling:
     # Since gevent.wsgi executes each incoming connection in a separate greenlet
     # long running requests such as this one don't block one another;
     # becomes greenlet-local storage thus making requests isolated as they should be.
     def GET(self):
         print 'handling GET context id = %s' % (id(web.ctx._getd()), )
-        gevent.sleep(10) # possible to block the request indefinitely, without harming others
+        gevent.sleep(10)  # possible to block the request indefinitely, without harming others
         return 'Hello, 10 seconds later'
 
 if __name__ == "__main__":
     application = web.application(urls, globals()).wsgifunc()
     print 'Serving on 8088...'
     WSGIServer(('', 8088), application).serve_forever()
-

examples/wsgiserver.py

 
 from gevent import wsgi
 
+
 def hello_world(env, start_response):
     if env['PATH_INFO'] == '/':
         start_response('200 OK', [('Content-Type', 'text/html')])
 
 print 'Serving on 8088...'
 wsgi.WSGIServer(('', 8088), hello_world).serve_forever()
-

examples/wsgiserver_ssl.py

 
 from gevent import pywsgi
 
+
 def hello_world(env, start_response):
     if env['PATH_INFO'] == '/':
         start_response('200 OK', [('Content-Type', 'text/html')])
 # to start the server asynchronously, call server.start()
 # we use blocking serve_forever() here because we have no other jobs
 server.serve_forever()
-