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

Irmen de Jong <[email protected]> Wed, 07 Jan 2015 23:24:15 +0100
Newsgroups gmane.comp.python.pyro
Message-ID <[email protected]>
On 7-1-2015 16:58, Kenneth Martin wrote:
> 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

typo here, the environment vars are prefixed with PYRO_    So you must type:
export PYRO_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))

which is why you get this error (from the name server) that someone is trying to connect
to it using pickle (which you inadvertently didn't enable correctly).


> 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:

Calm down a moment here, the locking mechanism has nothing to do with this.

First fix your understanding of and setting of the serializer mechanisms.

Have you tried the warehouse tutorial first?

Have you stopped all running python processes that you started for that? Most
importantly, the name server.
For the stockmarket tutorial you have to start with no running servers.


To be sure I've just done the steps written in
http://pythonhosted.org/Pyro4/tutorials.html#running-the-final-program myself and
everything is working fine.
(tried it on Windows and Ubuntu) Maybe it helps to include the console output I'm
getting in each console, see the dumps at the end of this message.

You're mixing up some things on your end.
Also note that, for the stockmarket example, it is required to use pickle instead of
serpent. Stop trying to switch serializers to see what is working; it *has* to be pickle
for the name server and the three programs from the stockmarket tutorial.
The programs set this themselves (in the first few lines of each module) but for the
name server you have to do this via the aforementioned env var.


Irmen

PS the source files of both tutorials are available in the examples directory

PPS console outputs:
------output from name server console------
irmen@xubuntu:~/projects/Pyro4/src$ export PYRO_SERIALIZERS_ACCEPTED=pickle
irmen@xubuntu:~/projects/Pyro4/src$ python -m Pyro4.naming
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
------------------------

------output from stockmarket.py console-------
irmen@xubuntu:~/projects/Pyro4/examples/stockquotes/phase3$
PYTHONPATH=~/projects/Pyro4/src python stockmarket.py
Stockmarkets running.
new quotes generated for NYSE
new quotes generated for NASDAQ
new quotes generated for NYSE
new quotes generated for NYSE
new quotes generated for NASDAQ
new quotes generated for NASDAQ
....
---------------------------------------

-------output from aggregator.py console-----------------
irmen@xubuntu:~/projects/Pyro4/examples/stockquotes/phase3$
PYTHONPATH=~/projects/Pyro4/src python aggregator.py
joining market example.stockmarket.newyork
joining market example.stockmarket.nasdaq
Aggregator running. Symbols: ['HPQ', 'BP', 'IBM', 'GOOG', 'AAPL', 'CSCO', 'MSFT']
aggregator gets a new viewer, for symbols: ['AAPL', 'MSFT']
-----------------------------------

---------output from viewer console-------------
irmen@xubuntu:~/projects/Pyro4/examples/stockquotes/phase3$
PYTHONPATH=~/projects/Pyro4/src python viewer.py
Available stock symbols: ['HPQ', 'BP', 'IBM', 'GOOG', 'AAPL', 'CSCO', 'MSFT']
Enter symbols you want to view (comma separated):AAPL,MSFT
Viewer listening on symbols ['AAPL', 'MSFT']
NASDAQ.MSFT: 133.47
NASDAQ.MSFT: 96.63
NASDAQ.AAPL: 203.29
NASDAQ.MSFT: 142.93
NASDAQ.AAPL: 211.85
NASDAQ.AAPL: 168.61
...
----------------------------------------



------------------------------------------------------------------------------
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