ZeroRPC and UI loop

127 views
Skip to first unread message

Sébastien

unread,
Jul 1, 2014, 3:27:46 PM7/1/14
to zer...@googlegroups.com
Hello,

I'm trying to develop a kind of basic simulator software and I would like to be able to interact
with it using IPC and RPC.
So my script (for now it's just a text user interface) have an infinite loop.

I would like to know what is the best way to include ZeroRPC into my script because there is
2 infinite loops : one for UI (run method of DrillSimulator) and one for ZeroRPC server (run method of zerorpc.Server).

I have nearly no experience with multithreading, gevent, greenlet... but I hope you can help.

server is in "drill_sim.py" file
client is "drill_remote_client.py"

Kind regards

Sébastien
drill_remote_client.py
drill_sim.py
system_simulator.py
logging.conf

Sébastien

unread,
Jul 1, 2014, 4:11:54 PM7/1/14
to zer...@googlegroups.com
Sorry I forget to add that I tried
thread.start_new_thread(start_server, (endpoint, resolve))
before running UI loop but I get
    raise NotImplementedError('gevent is only usable from a single thread')
NotImplementedError: gevent is only usable from a single thread


I also tried using
from concurrent.futures import ThreadPoolExecutor
but I couldn't find a way to make my simple script working correctly

Any idea?

Andreu Correa Casablanca

unread,
Jul 3, 2014, 5:25:53 PM7/3/14
to zer...@googlegroups.com
Hello,


El martes, 1 de julio de 2014 22:11:54 UTC+2, Sébastien escribió:
Sorry I forget to add that I tried
thread.start_new_thread(start_server, (endpoint, resolve))
before running UI loop but I get
    raise NotImplementedError('gevent is only usable from a single thread')
NotImplementedError: gevent is only usable from a single thread


ZeroRPC uses Gevent in it's internals. Gevent uses Greenlets, which are an alternative to classic threads.
Greenlets are a form of cooperative scheduling threading, while classic threads are preemptive scheduling
threading.

(Gevent has methods to "monkey  patch" all the relevant IO libraries in order
to yield the CPU when the greenlet has to wait for IO responses)

Maybe because this you're experiencing problems with thread pools.

 

s.ce...@gmail.com

unread,
Jul 4, 2014, 1:36:37 AM7/4/14
to zer...@googlegroups.com
Thanks

So what is possible to do if I want to have a thread for UI and an other thread waiting RPC ?

Is it possible to do it using ZeroRPC ?

Kind regards

Sébastien


--
You received this message because you are subscribed to a topic in the Google Groups "zerorpc" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/zerorpc/_LdFqXI76rU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to zerorpc+u...@googlegroups.com.
To post to this group, send email to zer...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/zerorpc/e9fcf427-12f2-41c7-bd24-777889a55753%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages