Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python asyncore & dbus

Is it possible to integrate asyncore with dbus through the same main loop?

Usually, DBus integration is done through glib main loop: is it possible to have either asyncore integrate this main loop or have dbus use asyncore's ?

like image 941
jldupont Avatar asked Jan 27 '10 18:01

jldupont


People also ask

What is Asyncore in Python?

The asyncore module provides a “reactive” socket implementation. Instead of creating socket objects and calling methods on them to do things, this module allows you to write code that is called when something can be done.

What does Asyncore loop do?

The asyncore. loop function starts the underlying channel services. These channel services can be instances of classes that inherit the asyncore.


2 Answers

asyncore sucks. glib already provides async stuff, so just use glib's mainloop to do everything.

like image 109
nosklo Avatar answered Sep 30 '22 17:09

nosklo


I wrote a trivial GSource wrapper for one of my own projects called AsyncoreGSource

Just attach it to an appropriate MainContext:

source = AsyncoreGSource([socket_map])
source.attach([main_context])

Naturally the defaults are asyncore.socket_map and the default MainContext respectively.

You can also try monkey-patching asyncore.socket_map, which would have been my solution had I not poked through the GLib python bindings source code for GSource.

like image 28
Matt Joiner Avatar answered Sep 30 '22 18:09

Matt Joiner