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

Kenneth Martin <martin-TxPoQvD3IN4C6LszWs/[email protected]> Wed, 07 Jan 2015 17:55:36 -0500
Newsgroups gmane.comp.python.pyro
Message-ID <[email protected]>
Irmen, thank you very much. I copied the environment variable from the 
example files assuming the name was the same as that used
for Pyro4.config and didn't pick up that the environment names needed 
PYRO_ in front of them. I have gone back and read the doc on
"Configuring Pyro" and now see I can use >pyro4-check-config to verify 
my configuration. I'll put this error down to start-up
stupidity. Just as an aside, when I change the config lines in the 
example files to serpent, it does seem to run correctly as far as I
can tell. Small suggestion: add a few lines to tutorial to check 
configuration before running name server; perhaps something like:
 >pyro4-check-config | grep -i serial
Thanks again.
Bit_Pusher
p.s. a few answers below (not important)

On 15-01-07 05:24 PM, Irmen de Jong wrote:
> 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
Yech!
>
>>   > 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?
Yes, worked fine
>
> Have you stopped all running python processes that you started for that? Most
> importantly, the name server.
Yes
> For the stockmarket tutorial you have to start with no running servers.
I checked for this (I have an alias pg='ps aux | grep -i') and I always 
run >pg python
>
>
> 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.
It does seem to work with serpent for me when I change the two lines 
from each file.
I tried serpent when I couldn't get it to run as according to the 
tutorial due to naming
the environment variables incorrectly. Is it possible to check the 
environment variables matching
Pyro4.config variables and report any inconsitencies; thid could 
possibly be done when config variables
are set?
>
>
> Irmen
>
> PS the source files of both tutorials are available in the examples directory
Yes, I am running the example files
>
> 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
> _______________________________________________
> 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

_______________________________________________
Pyro-core mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/pyro-core