Git Product home page Git Product logo

gevent-tutorial's Introduction

Want to add an example. Its uber simple.

  1. Fork the repo.
  2. pip install -r requirements.txt
  3. Edit tutorial.md.

Add your text as Markdown.

Add your code as Cog:

 [[[cog

 print("Hello World!")
 for i in xrange(25):
     print(i)

 ]]]
 [[[end]]]

Will output this as html:

<pre>
<code class="python">

print("Hello World!")
for i in xrange(5):
    print(i)

</code>
</pre>

<pre><code class="python">
Hello World!
0
1
2
3
4
</code>
</pre>
  1. Run ./build
  2. Issue pull request.
  3. Get good gevent karma.

Released under MIT License.

Copyright (c) 2011 Stephen Diehl, <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

gevent-tutorial's People

Contributors

abhijaygh avatar adaszko avatar ajamesphillips avatar bbigras avatar bubanoid avatar davidxia avatar dhamaniasad avatar djheru avatar djv avatar eclipselu avatar ehebert avatar harudark avatar iepathos avatar jerem avatar jgehrcke avatar kitelife avatar lothiraldan avatar macrotim avatar matiasherranz-santex avatar methane avatar pbertera avatar ramiro avatar roysmith avatar scottgwald avatar sdiehl avatar suzaku avatar sww avatar tmc avatar zhangchunlin avatar zr40 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gevent-tutorial's Issues

Incorrect reference of libev on home page

On gevent tutorial page it say:
"gevent is a concurrency library based around libev. It provides a clean API for a variety of concurrency and network related tasks."

Gevent is based on libevent (http://libevent.org/) and NOT libev (http://software.schmorp.de/pkg/libev.html). Check out http://www.gevent.org/ for more information.

Quick reference:
"gevent is a coroutine-based Python networking library that uses greenlet to provide a high-level synchronous API on top of the libevent event loop."

Multiprocessing example does not work in Windows

The code example using Multiprocessing with wait_write and wait_read does not work on Windows (tested on Windows 7).

In Gevent 1.0b2, an example error message is:

IOError: 496 is not a socket (files are not supported)
<Greenlet at 0x2e30a60L: get_msg> failed with IOError

In pre1.0 versions of gevent the error is less specific:

IOError: [Errno 2] No such file or directory

I am curious about the underlying reason for the errors. I know Windows lacks the "socket is a socket" functionality of POSIX, but in vanilla python select() works with Multiprocessing pipes... I haven't looked too deeply at the issue but I suppose the standard library uses WinSock for the pipes and gevent does not?

Full traceback here:

Traceback (most recent call last):
  File "C:\Python27\lib\site-packages\gevent\greenlet.py", line 328, in run
    result = self._run(*self.args, **self.kwargs)
  File "C:\Users\user\Desktop\prj\gevent_multiprocess_example.py", line 23, in get_msg
    wait_read(d.fileno())
  File "C:\Python27\lib\site-packages\gevent\socket.py", line 160, in wait_read
    io = get_hub().loop.io(fileno, 1)
  File "core.pyx", line 406, in gevent.core.loop.io (gevent/gevent.core.c:6413)
  File "core.pyx", line 656, in gevent.core.io.__init__ (gevent/gevent.core.c:10369)
IOError: 496 is not a socket (files are not supported)
<Greenlet at 0x2e30a60L: get_msg> failed with IOError

Use of the word emplict might be a misspelling

A couple times in the tutorial, the word 'emplict' is used.

e.g.:
print('Emplict context switch to foo again')

I'm not exactly sure that's a word. (At least I can't find any reference to it in dictionaries/online.)

Trying to figure it out from the context... but is the use of 'emplict' supposed to mean 'implicit' or 'explicit'?

gevent.shutdown doesn't exist in gevent 1.0b2

The Program Shutdown section suggests coupling gevent.event with gevent.shutdown to cause a program to exit immediately. gevent.shutdown doesn't exist in gevent 1.0b2, and it seems that this behavior is builtin autoamatically now (through the use of gevent.hub.Hub.SYSTEM_ERROR.

It would be nice if the tutorial mentioned this (or alternatively mentioned the tutorial was written for gevent 0.13.7 or earlier) as not to cause confusion when an AttributeError is raised.

Get AttributeError when running the `gevent_zeromq` example

Traceback (most recent call last):
  File "/home/vagrant/.py_venvs/test/local/lib/python2.7/site-packages/gevent/greenlet.py", line 390, in run
    result = self._run(*self.args, **self.kwargs)
  File "gzmq.py", line 19, in client
    client_socket = context.socket(zmq.REP)
  File "/home/vagrant/.py_venvs/test/local/lib/python2.7/site-packages/zmq/sugar/context.py", line 82, in socket
    s = self._socket_class(self, socket_type)
  File "/home/vagrant/.py_venvs/test/local/lib/python2.7/site-packages/gevent_zeromq/core.py", line 36, in __init__
    self.__in_send_multipart = False
  File "/home/vagrant/.py_venvs/test/local/lib/python2.7/site-packages/zmq/sugar/attrsettr.py", line 38, in __setattr__
    self.__class__.__name__, upper_key)
AttributeError: GreenSocket has no such option: _GREENSOCKET__IN_SEND_MULTIPART
<Greenlet at 0x7f678ba41910: client> failed with AttributeError

Mismatched gif and code

The code shows:

def foo():
    print('Running in foo')
    gevent.sleep(0)
    print('Explicit context switch to foo again')

But the gif shows a typo:

image

And makes me wonder whether it should be explicit or implicit ๐Ÿ˜„

Build Warning

When I run to build:

~$ ./build
Traceback (most recent call last):
  File "/Users/G_will/Works/python/gevent-tutorial/lib/python2.7/site-packages/gevent/greenlet.py", line 390, in run
    result = self._run(*self.args, **self.kwargs)
  File "tutorial.md+367", line 8, in fail
Exception: You fail at failing.
<Greenlet at 0x1066af4b0: fail> failed with Exception

Wrote index.html

What's wrong? The output index.html seems right.

TOC-sidebar boldface bug

There seem to be several small issues with the sidebar. One of them is that when I click on Core>Timeouts, what actually becomes bold is either "Program Shutdown" or "Monkeypatching". The page scrolls to the right anchor, but the highlighting in the TOC is shifted. I'm using Firefox 18.

I was playing around with the subsections in "Data Structures" (when building new versions of the tutorial) and observed the same behavior there when more than 7 subsections were existing in that section.

some confusion about libev and libevent

Hi,

great stuff, thanks for working on it.

There's some confusion about libev and libevent. Let me clarify.

gevent 0.x is based on libevent. libevent includes and http servers. gevent 0.x provides wrappers for (gevent.http and gevent.wsgi modules). There's also pure Python WSGI server, called gevent.pywsgi

gevent 1.x is based on libev. libev does not have an HTTP server bundled and we currently don't have a replacement. so gevent.http is missing from gevent 1.x and gevent.wsgi is an alias for gevent.pywsgi.

This sentence is wrong: "wsgi is a Python bridge to libev's very fast HTTP server.", as you see from above, libev has no fast HTTP server and gevent 1.x currently has only pure Python HTTP server which is not as fast as gevent 0.x's gevent.wsgi is.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.