开发者

Integrating cmd.cmdloop and gobject.MainLoop()

So I have written a small console application based on cmd.Cmd. The application has a command loop triggered by cmd.cmdloop

On the other hand, my console application uses dbus to launch remote processes. I'm trying to make the laumch asyncronous, but I get

RuntimeError: To make asynchronous calls, receive signals or export objects, D-Bus
connections must be attached to a main loop by passing mainloop=... to the constructor or
calling dbus.set_d开发者_如何学运维efault_main_loop(...)

So I would like to use gobject.MainLoop() as the main loop.

Is there a way that cmd.cmdloop and gobject.MainLoop can play together?


It looks like cmd.cmdloop isn't a main loop, just a way to get input from a user over-and-over. Your best bet here, if you want to make this as asynchronous as possible, and you're already using dbus may be to have a client process which uses cmd.cmdloop and sends signals to another process that uses the gobject mainloop to actually launch the remote processes. The client process would send signals to the gobject process which contain the command to run, the gobject process would execute them. I'm not sure this will do what you want it to do, but it looks like cmd.cmdloop blocks on user input and as such won't play nicely with a mainloop.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜