Re: locateNS() hangs when running stockquotes example in tutorial

Kenneth Martin <martin-TxPoQvD3IN4C6LszWs/[email protected]> Wed, 07 Jan 2015 10:58:32 -0500
Newsgroups gmane.comp.python.pyro
Message-ID <[email protected]>
I just carefully started up the stockquotes example again. Here is a 
copy of my terminal when starting the name server and stockmarket.py

 > export SERIALIZERS_ACCEPTED=pickle
 > pyro4-ns &
[1] 1794
 > Not starting broadcast server for localhost.
NS running on localhost:9090 (127.0.0.1)
Warning: HMAC key not set. Anyone can connect to this server!
URI = PYRO:Pyro.NameServer@localhost:9090

 > python stockmarket.py &
[2] 1817
 > /usr/local/lib/python2.7/dist-packages/Pyro4/naming.py:211: 
UserWarning: Pyro protocol error occurred: message used serializer that 
is not accepted: 4
   warnings.warn("Pyro protocol error occurred: " + str(x))

The serializer specifications in stockmarket.py are the same as the 
tutorial:
from __future__ import print_function
import random
import threading
import time

import Pyro4


Pyro4.config.SERIALIZER = 'pickle'
Pyro4.config.SERIALIZERS_ACCEPTED.add('pickle')

I killed the job and started it a second time; there was no output, so I 
started tracking down where it was hanging using winpdb. It is hanging at:

naming.py:365 proxy.ping() to core.py: 231 self._pyroGetMetadata() to 
core.py: 475 self.__pyroCreateConnection() to core.py: 421 with 
self.__pyroLock:

It is waiting to get the lock. I opened core.py and searching for the 
lock found:        Line 203:  self.__pyroLock = threadutil.Lock()
I checked Pyro4.config.THREADING2 and it is False, so it appears 
threading is not getting self.__pyroLock. This is as far as I got. I 
then continued in winpdb and core.py is still hung. I did a break, and 
it is sitting at core.py: 327, in def _pyroRelease(self): at the line: 
with self.__pyroConnLock:

This is the same place is was hung yesterday. I then killed all jobs, 
changed the serializer everywhere to serpent, the tutorial worked as 
expected. I then
killed all jobs again, changed back to pickle everywhere, stockmarket.py 
is hanging again, with the terminal message:

 > /usr/local/lib/python2.7/dist-packages/Pyro4/naming.py:211: 
UserWarning: Pyro protocol error occurred: message used serializer that 
is not accepted: 4
   warnings.warn("Pyro protocol error occurred: " + str(x))

I then went back to pickle, which had worked previously, and the name 
server, stockmarket.py,  and aggregator.py all started properly, but now 
viewer.py hung. I had to change line 27 to

     available_symbols = aggregator.available_symbols()
     print("Available stock symbols:", available_symbols)

as it is actually the aggregator proxy that is hanging. I tracked it 
down as far as line 466 in core.py: self._pyroGetMetadata(uri.object) in
def __pyroCreateConnection(self, replaceUri=False):

The stack at this point is:

0 core.;py 466
1 core.py 475
2 core.py 231
3 naming.py 365
4 naming.py 441
5 core.py 416
6 core.py 475
7 core.py 231
8 viewer.py 27
9 viewer.py 37

This is as far as I have time for this morning. Could it be an issue of 
not enough threads or not enough locks? Thanks.
Bit_Pusher



On 15-01-06 07:21 PM, Irmen de Jong wrote:
> On 7-1-2015 0:06, Kenneth Martin wrote:
>> Disclaimer, I'm brand new to Pyro4 and may be doing something stupid.
> Maybe, maybe not! Welcome either way :)
>
>> Details: running Debian Linux beaglebone 3.8.13-bone47 #1 SMP Fri Apr 11 01:36:09 UTC
>> 2014 armv7l GNU/Linux
>> on a Beaglebone Black C.
>> Pyro4: 4.31
>>
>> I set the environment variable per tutorial:
>> export PYRO_SERIALIZERS_ACCEPTED=pickle, but I may have done this after running >pyro4-ns &
> Yes, setting it after starting the name server won't do much. The name server needs to
> pick it up when it is started in order to use the correct mode.
> You'll have to make sure that the environment variables have the correct value before
> starting the name server (or any Pyro server, for that matter).
>
> I'll clarify the steps in the tutorial chapter a bit more to make this perfectly clear.
>
>
>> When running the stockquote tutorial phase 3, I determined using winpdb that
>> aggregator.py was hanging on line 34
>>      ns = Pyro4.locateNS()
> Hm, shouldn't hang. Will investigate a bit what happens in the scenario you're describing.
>
>
>> Summary, there may be a problem with the tutorial in 4.31 in an out of the box set-up.
> I don't agree: it works fine as long as the Ns is started after setting the environment
> variable ;)
>
>> Also, maybe some checks for consistency on serializers might help.
> What do you mean by this exactly?
>
>> Not sure if this helps, but for new users having the tutorials
>> work is so critical, I thought it might be worth taking the time, as Pyro4 looks like a
>> great module; Irmen, much appreciated.
> Thanks for the feedback!
>
> Irmen
>
>
> ------------------------------------------------------------------------------
> Dive into the World of Parallel Programming! The Go Parallel Website,
> sponsored by Intel and developed in partnership with Slashdot Media, is your
> hub for all things parallel software development, from weekly thought
> leadership blogs to news, videos, case studies, tutorials and more. Take a
> look and join the conversation now. http://goparallel.sourceforge.net
> _______________________________________________
> Pyro-core mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/pyro-core

-- 
Kenneth Martin, President
Granite SemiCom Inc.
555 Richmond St. W, BX1200/Suite 905
Toronto ON
416 640-2626, www.granitesemi.com


------------------------------------------------------------------------------
Dive into the World of Parallel Programming! The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net