libevent-python

chenchao at inhand.com.cn chenchao at inhand.com.cn
Thu Oct 8 05:32:56 EDT 2015


hi:
    I use libevent-python package currently. I read the file 
eventmodule.c, but I can not understand the function:

   static EventObject *EventBase_CreateEvent(EventBaseObject *self, 
PyObject *args, PyObject *kwargs)
  {
    EventObject *newEvent = NULL;

    newEvent = (EventObject *)Event_New(&Event_Type,NULL,NULL);

    if (Event_Init(newEvent, args, kwargs) < 0){
      return NULL;
    }

    if (PyObject_CallMethod((PyObject *)newEvent, "setEventBase", "O", 
self) == NULL){
      return NULL;
    }

    return newEvent;
  }

  So, I can not know the param "EventBaseObject *self" is what?  And I 
read the examples/echo_server.py file, I read the follow source:
    class BaseConnection(object):
     bufferSize = 2**16
     def __init__(self, sock, addr, server):
         self.sock = sock
         self.addr = addr
         self.server = server
         self.sock.setblocking(False)
         self.buf = []
         self.readEvent = libevent.createEvent(
             self.sock,libevent.EV_READ|libevent.EV_PERSIST, self._doRead)
         self.writeEvent = libevent.createEvent(
             self.sock,libevent.EV_WRITE, self._doWrite)
         self.startReading()
  So, I can not see pass the self parameter. Is anybody know this?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20151008/fbf60b9d/attachment.html>


More information about the Python-list mailing list