Experimental Physics and Industrial Control System
Andrew, Matt
On Wednesday 20 April 2011 Andrew Johnson wrote
>On Wednesday 20 April 2011 15:06:33 Matt Newville wrote:
>> On Wed, Apr 20, 2011 at 1:04 PM, Vigder, Mark
>> <[email protected]> wrote:
>> > 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.
>
>Assuming that epics.ca.context_create() results in a call to
>ca_context_create() then I worry that Mark's code ends up trying to use a chid
>created in one CA context (associated with the object m) in a thread that is
>running with a different CA context. Internally a chid has a reference to the
>context it was created in, and I have no idea what happens if you use one this
>way, but I'm fairly sure you're not supposed to.
>
>I would recommend that you share a single CA context across all the threads in
>your program unless you have a very good reason to not do that, it saves
>resources. To do that you'll need to find out what the PyEpics equivalents
>are of the routines ca_current_context() and ca_attach_context(), and pass the
>context pointer returned by calling ca_current_context() from the main thread
>into the new thread and there passing it to ca_attach_context().
>
>HTH,
>
>- Andrew
>--
I did a quick test and this seems to solve it. Appropriate calls in PyEpics are
ca.current_context() and ca.attach_context().
Maybe one day I'll come up with a good reason not to use the same CA context
across all Python threads, but I certainly don't have one today. I'm just
starting to figure out what chid's and contexts are all about in CA.
Thanks
Mark
- Replies:
- Re: PyEpics and Python threads Matt Newville
- References:
- PyEpics and Python threads Vigder, Mark
- Re: PyEpics and Python threads Matt Newville
- Re: PyEpics and Python threads Andrew Johnson
- Navigate by Date:
- Prev:
Re: PyEpics and Python threads Andrew Johnson
- Next:
creating Deb/RPM packages (with CMake) Martin Konrad
- 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:
Re: PyEpics and Python threads Andrew Johnson
- Next:
Re: PyEpics and Python threads Matt Newville
- 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