Hi Mark,
On Wed, Apr 20, 2011 at 1:04 PM, Vigder, Mark
<[email protected]> wrote:
> I'm working on getting PyEpics and Python threads to work together. I get a
> lot of
> inconsistent behaviour, but the following seems to be somewhat consistent.
> At least
> today it is. I have a motor record, 'L3:m1' and run the following:
>
> from threading import Thread
> import epics
> import random
> def th(pv, sp):
> epics.ca.context_create()
> pv.put(sp, wait=True)
> epics.ca.context_destroy()
> if __name__ == '__main__':
> d1=random.randrange(360)
> m = epics.PV('L3:m1')
> t1 = Thread(target=th, args=(m, d1))
> t1.start()
>
> When executing the 'pv.put' statement, this (almost) always sits for about
> 30 seconds
> doing nothing, and then moves the motor correctly. Why the 30 second delay?
>
> However, the following program usually (though not always) executes
> correctly
> without the 30 second delay.
>
> from threading import Thread
> import epics
> import random
> def th(pv, sp):
> epics.ca.context_create()
> pv.put(sp, wait=True)
> epics.ca.context_destroy()
> if __name__ == '__main__':
> d1=random.randrange(360)
> m = epics.PV('L3:m1')
> t1 = Thread(target=th, args=(m, d1))
> anyPV = epics.PV('L3:scan1')
> t1.start()
>
>
> The only difference is I created some arbitrary unrelated PV before starting
> the thread. I'm still
> trying to understand CA contexts, so I'm not sure those calls are necessary,
> but
> for some things I tried they seemed to be required. Other little changes,
> such as creating the
> PV object inside the thread rather than passing it in to the thread, also
> seem to eliminate the 30 second delay.
> Trying on my PC rather than linux co-hosted with IOC gives about a 10 second
> delay.
>
> Any help or explanations are well appreciated.
The default timeout for pv.put() in "put-with-wait" mode is 30
seconds, which is probably where that time is coming from.
It appears that the put-with-wait is not announcing completeness
across "contexts" (that is you create a PV in the main thread, then
create a new context in the created thread and do the put-with-wait on
the PV from the original thread). It's possible thatt the
put-with-wait is not complete enough for dealing with all thread cases
right now.
--Matt Newville
- Replies:
- Re: PyEpics and Python threads Andrew Johnson
- References:
- PyEpics and Python threads Vigder, Mark
- Navigate by Date:
- Prev:
Re: status of Debian/Ubuntu packages/repositories Michael Davidsaver
- Next:
Re: status of Debian/Ubuntu packages/repositories Bill Lavender
- Index:
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
<2011>
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
- Navigate by Thread:
- Prev:
PyEpics and Python threads Vigder, Mark
- Next:
Re: PyEpics and Python threads Andrew Johnson
- Index:
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
<2011>
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
|