Re: [Quickfix-developers] QuickFIX Python and Twisted
Brought to you by:
orenmnero
|
From: Robert P. <rob...@gm...> - 2006-11-15 23:15:46
|
BTW, looking at these macro definitions, it isn't as easy as inserting
the macros directly, since there are defined to be used in pairs,
before and after. Instead, for the callbacks there will need to be
either explicit code or new macros:
(from ceval.h of python 2.3 )
PyAPI_FUNC(void) PyEval_InitThreads(void);
PyAPI_FUNC(void) PyEval_AcquireLock(void);
PyAPI_FUNC(void) PyEval_ReleaseLock(void);
PyAPI_FUNC(void) PyEval_AcquireThread(PyThreadState *tstate);
PyAPI_FUNC(void) PyEval_ReleaseThread(PyThreadState *tstate);
PyAPI_FUNC(void) PyEval_ReInitThreads(void);
#define Py_BEGIN_ALLOW_THREADS { \
PyThreadState *_save; \
_save = PyEval_SaveThread();
#define Py_BLOCK_THREADS PyEval_RestoreThread(_save);
#define Py_UNBLOCK_THREADS _save = PyEval_SaveThread();
#define Py_END_ALLOW_THREADS PyEval_RestoreThread(_save); \
}
On 11/15/06, Robert Parrott <rob...@gm...> wrote:
> Makes sense. And since the point was to use an asynchronous threaded
> package like twisted, these callbacks can be made to be non-blocking.
>
> So these changes would need to be made in the quickfix.i code?
>
> rob
>
>
> On 11/15/06, Oren Miller <or...@qu...> wrote:
> > The allow threads macros I believe were explicitly designed for
> > blocking IO calls, you can read mode about it here: http://
> > www.gmu.edu/mlnavbar/webdev/doc-python/api/threads.html
> >
> > I would think that an IO library like one that does database queries
> > is most likely aware of this and will implement these macros. As
> > long as they do, it should not be a problem since we called the end
> > macro, they would be able to call the begin macro, then the end
> > macro, allowing us to call the begin macro again.
> >
> > --oren
> >
> > On Nov 15, 2006, at 3:01 PM, Robert Parrott wrote:
> >
> > > This sounds reasonable enough to me, but I'm not familiar with
> > > python threading.
> > >
> > > What happens if the python callbacks are long running (i.e. SQL
> > > query). Would it block the main quickfix loop in this case?
> >
> >
>
|