> On 04 Nov 2015, at 17:38, Martin Patzak (GMX) <martin.pat...@gmx.de> wrote:
> 
> Stefano,
> 
> thanks for bringing pyownet to my attention. I definitely will try it out.
> 
> 
> 
> On 11/04/2015 03:56 PM, Stefano Miccoli wrote:
>> Minimal instruction for use are
>> >>> from pyownet import protocol
>> >>> owproxy = protocol.proxy(host="server.example.com 
>> >>> <http://server.example.com/>", port=4304)
>> >>> owproxy.dir()
>> [u'/10.A7F1D92A82C8/', u'/05.D8FE434D9855/', u'/26.8CE2B3471711/']
>> >>> owproxy.read('/10.A7F1D92A82C8/temperature')
>> '     6.68422'
> thanks for the quick-kick-start
> 
>> The only thing you should be aware of is that creating an owproxy object is 
>> quite time consuming, so usually you have a single owproxy instance, shared 
>> globally.
> I have several tasks writing independently to owfs. The tasks stay alive and 
> so I would have to create an owproxy only once during startup... 
> Would there be a drawback to that procedure?

There is no drawback, this is the correct way to go, for non-persistent 
connections (which are the default), see  
http://pyownet.readthedocs.org/en/latest/protocol.html#persistent-vs-non-persistent-proxy-objects
 
<http://pyownet.readthedocs.org/en/latest/protocol.html#persistent-vs-non-persistent-proxy-objects>.
 Non persistent owproxy should be thread safe (but I’ve done no extensive 
testing) so no problem here.

Non-persistent means that you bind and tear down a new socket for each owserver 
operation (read, write, etc.). New socket binding is less than 1ms overhead on 
my test machine, so usually I do not care.

Just a few numbers, collected with 
https://github.com/miccoli/pyownet/blob/master/test/timing.py 
<https://github.com/miccoli/pyownet/blob/master/test/timing.py> querying a non 
localhost production owserver


pyownet: ver. 0.8.2
proxy_obj: ownet server at ('10.48.74.112', 4304)
server info: pid 2662, ver. unknown

timeit:
 statement: proxy_obj.dir("/")
 number: 20
 repetitions: 5

** non persistent :  1.29 ms,  1.30 ms,  1.30 ms,  1.33 ms,  1.36 ms,
** persistent     :  0.77 ms,  0.77 ms,  0.79 ms,  0.80 ms,  0.97 ms,


timeit:
 statement: proxy_obj.read("/26.xxxxxxxxxxxx/temperature")
 number: 20
 repetitions: 5

** non persistent :  1.14 ms,  1.16 ms,  1.16 ms,  1.19 ms,  1.40 ms,
** persistent     :  0.63 ms,  0.64 ms,  0.66 ms,  0.95 ms,  0.98 ms,


The figure reported here are time for a single call to the given method, 
computed as the average of 20 consecutive calls.
(Please note that I read the cached temperature value… uncached is of course 
much slower, but this is due to 1-wire)
Just to put numbers in the correct perspective:

$ ping -c 5 10.48.74.112
PING 10.48.74.112 (10.48.74.112): 56 data bytes
64 bytes from 10.48.74.112: icmp_seq=0 ttl=64 time=0.478 ms
64 bytes from 10.48.74.112: icmp_seq=1 ttl=64 time=0.701 ms
64 bytes from 10.48.74.112: icmp_seq=2 ttl=64 time=0.563 ms
64 bytes from 10.48.74.112: icmp_seq=3 ttl=64 time=0.563 ms
64 bytes from 10.48.74.112: icmp_seq=4 ttl=64 time=0.587 ms

--- 10.48.74.112 ping statistics ---
5 packets transmitted, 5 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 0.478/0.578/0.701/0.072 ms

Stefano

>  
> Thanks for your input,
> 
> Martin
> 
> ------------------------------------------------------------------------------
> _______________________________________________
> Owfs-developers mailing list
> Owfs-developers@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/owfs-developers

------------------------------------------------------------------------------
_______________________________________________
Owfs-developers mailing list
Owfs-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/owfs-developers

Reply via email to