Re: Python extension module with callbacks into Python

2020-10-29 Thread Paul Grinberg
> > Can you please clarify where/when I should call PyEval_InitThreads()? Is > > this in the main python thread before any pthread callbacks are generated? > > If so, should this be done only once? > Do it in your module init. That function is safe to be called multiple time. > I decided to

Re: Python extension module with callbacks into Python

2020-10-28 Thread Barry
> On 28 Oct 2020, at 15:22, Paul Grinberg wrote: > >  >> >> Try calling PyEval_InitThreads() to force the python threading to be all >> setup. > > Can you please clarify where/when I should call PyEval_InitThreads()? Is this > in the main python thread before any pthread callbacks are

Re: Python extension module with callbacks into Python

2020-10-28 Thread Paul Grinberg
> Try calling PyEval_InitThreads() to force the python threading to be all > setup. Can you please clarify where/when I should call PyEval_InitThreads()? Is this in the main python thread before any pthread callbacks are generated? If so, should this be done only once? --

Re: Python extension module with callbacks into Python

2020-10-28 Thread Barry Scott
> On 28 Oct 2020, at 13:25, Paul Grinberg wrote: > >>> I am running into unpredictable behavior with my Python extension module >>> that wraps around a C++ library that starts a new pthread and, after doing >>> some work, generates callbacks back into the caller. I've greatly >>>

Re: Python extension module with callbacks into Python

2020-10-28 Thread Paul Grinberg
> > I am running into unpredictable behavior with my Python extension module > > that wraps around a C++ library that starts a new pthread and, after doing > > some work, generates callbacks back into the caller. I've greatly > > simplified this to a simplistic example which still demonstrates

Re: Python extension module with callbacks into Python

2020-10-28 Thread Barry Scott
/stackoverflow.com/questions/64559322/python-extension-module-with-callbacks-into-python > > I am running into unpredictable behavior with my Python extension module that > wraps around a C++ library that starts a new pthread and, after doing some > work, generates callbacks back into the c

Python extension module with callbacks into Python

2020-10-27 Thread Paul Grinberg
As full disclosure, I posted this question on StackOverflow as well, but it looks like questions with [Python] [Extension-Module] tags are not frequently answered. The link to my question there is https://stackoverflow.com/questions/64559322/python-extension-module-with-callbacks-into-python I

Re: callbacks in python

2008-08-14 Thread Bruno Desthuilliers
Alexandru Mosoi a écrit : does anyone know a nice implementation of callbacks in python? i have issues mixing named unamed parameters. i want build a callback over a function such that some parameters are passed when callback is created and the rest are passed when the function is called

Re: callbacks in python

2008-08-14 Thread Fredrik Lundh
Bruno Desthuilliers wrote: from functools import partial callback = partial(some_func, x=1, y) callback(z, t=4, u) from functools import partial callback = partial(some_func, x=1, y) File stdin, line 1 SyntaxError: non-keyword arg after keyword arg --

Re: callbacks in python

2008-08-14 Thread Bruno Desthuilliers
Bruno Desthuilliers a écrit : Alexandru Mosoi a écrit : does anyone know a nice implementation of callbacks in python? i have issues mixing named unamed parameters. i want build a callback over a function such that some parameters are passed when callback is created and the rest are passed

Re: callbacks in python

2008-08-14 Thread Bruno Desthuilliers
Fredrik Lundh a écrit : Bruno Desthuilliers wrote: from functools import partial callback = partial(some_func, x=1, y) callback(z, t=4, u) from functools import partial callback = partial(some_func, x=1, y) File stdin, line 1 SyntaxError: non-keyword arg after keyword arg Yeps, I

callbacks in python

2008-08-13 Thread Alexandru Mosoi
does anyone know a nice implementation of callbacks in python? i have issues mixing named unamed parameters. i want build a callback over a function such that some parameters are passed when callback is created and the rest are passed when the function is called. example: callback = Callback

Re: callbacks in python

2008-08-13 Thread Fredrik Lundh
Alexandru Mosoi wrote: does anyone know a nice implementation of callbacks in python? i have issues mixing named unamed parameters. i want build a callback over a function such that some parameters are passed when callback is created and the rest are passed when the function is called

Re: callbacks in python

2008-08-13 Thread Larry Bates
Alexandru Mosoi wrote: does anyone know a nice implementation of callbacks in python? i have issues mixing named unamed parameters. i want build a callback over a function such that some parameters are passed when callback is created and the rest are passed when the function is called. example

Re: callbacks in python

2008-08-13 Thread Alexandru Mosoi
On Aug 14, 12:02 am, Fredrik Lundh [EMAIL PROTECTED] wrote: your use of the word callback is a bit unusual, and your example isn't valid Python code, but it looks as if functools.partial might be what you need:      http://docs.python.org/lib/module-functools.html my current implementation

Re: callbacks in python

2008-08-13 Thread Larry Bates
Alexandru Mosoi wrote: On Aug 14, 12:02 am, Fredrik Lundh [EMAIL PROTECTED] wrote: your use of the word callback is a bit unusual, and your example isn't valid Python code, but it looks as if functools.partial might be what you need: http://docs.python.org/lib/module-functools.html my

Re: COM callbacks in Python

2006-03-29 Thread Dan
One final note, The code posted does work. Unfortunately, the event only fires for the ADO connection who actually triggered the event. In my opinion, completely useless event. So the Python worked, The ADO does not do what its name implies. Thanks to all. Dan --

Re: COM callbacks in Python

2006-03-24 Thread Dan
Looked at the makepy, code now looks like this: import win32com.client import win32gui import time import pythoncom finished = 0 defaultNamedNotOptArg=pythoncom.Empty class ADOEvents: def OnRecordsetChangeComplete(self, adReason=defaultNamedNotOptArg, pError=defaultNamedNotOptArg,

Re: COM callbacks in Python

2006-03-24 Thread Dan
Ok, seems to fire at least once now, had to implement OnWillChangeRecordset as well. Definitely don't have to implement all the events though. Still not sure why its not acting like it should. Maybe I am looking at the wrong event? I want to know if the database has changed when someone else

COM callbacks in Python

2006-03-23 Thread Dan
I need to register for a COM callback under Windows. I am using an ADO recordset interface like this: import win32com.client import time connect = win32com.client.Dispatch(ADODB.Connection) recordset = win32com.client.Dispatch(ADODB.Recordset)

Re: COM callbacks in Python

2006-03-23 Thread Roger Upole
Dan [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] I need to register for a COM callback under Windows. I am using an ADO recordset interface like this: import win32com.client import time connect = win32com.client.Dispatch(ADODB.Connection) recordset =