Accessing reference on client machine

27 views
Skip to first unread message

Eyal Cohen

unread,
Mar 23, 2015, 4:45:01 AM3/23/15
to rp...@googlegroups.com
Hey All,

This is the first time I'm writing on this group.

I have being using rpyc for more that 3 years now. It is a great package!!!

I encounter a scenario that is stuck in a deadlock and I would like to know what am I doing wrong here.

I'm using rpyc 3.2.3 with python 2.7.8.

This is the code that reproduce the issue:

script file:
>> cat /tmp/script_lock.py
from threading import Lock
from time import sleep
lock = Lock()

def deadlock_repro(a):
    print type(a)
    with lock: # Thread-2 will be lock here 
        print 'going to sleep'
        sleep(1)
        print 'trying to access a'
        print a # Thread-1 will be lock here
        print 'finish'

------ 

open a new rpyc_classic.py on port 5555:
>> rpyc_classic.py -p 5555


-----

running the following python code:
>> python
from threading import Thread
import rpyc
conn = rpyc.classic.connect('localhost', 5555)
conn.modules["sys"].path += ["/tmp"]

t1 = Thread(target=conn.modules["script_lock"].deadlock_repro, args=(range(10),) )
t2 = Thread(target=conn.modules["script_lock"].deadlock_repro, args=(range(10),) )

t1.start()
t2.start()

t1.join() # this will never join 

-----

here is an output example of the rpyc_classic:

[root@clx-0128 tmp]# rpyc_classic.py -p 5555
INFO:SLAVE/5555:server started on [0.0.0.0]:5555
INFO:SLAVE/5555:accepted ('127.0.0.1', 33495)
INFO:SLAVE/5555:welcome ('127.0.0.1', 33495)
<netref class '__builtin__.list'>
going to sleep
trying to access a
<netref class '__builtin__.list'>


Can someone please explain me what I'm doing wrong here?

Thanks
Eyal Cohen.



Reply all
Reply to author
Forward
0 new messages