jing guo jing guo - 14 days ago 6
C++ Question

python,epoll.register(fd, eventmask) only has two parameters, how could I to use event.data_ptr like c++?

I use python's epoll but it can't use event.data.ptr like in c++.

Sometimes I will register class A.fd and sometimes I will register class B.fd.

So, when

epoll.poll()
returned, how can I know whether
fd
belongs to class A or B?

Answer

You can always maintain a separate map from fd to A or B. Then when an event gets triggered, lookup based on fd. Doesn't look like epoll has a richer interface, even in Python 3+

Comments