Python ctypes DLL method call works interactively, only one call as script -



Python ctypes DLL method call works interactively, only one call as script -

i need utilize dll (of don't have source) communicate other process. i'm using ctypes, so:

gcs = cdll('some_dll.dll') gcs.comm_init(byref(socket_id), 0, 'localhost') data_out = (c_double*3)(); data_in = (c_double*3)(); while true: rv = gcs.comm_exchange(byref(socket_id), data_in, data_out) if rv == communication_return_code['success']: print('received data_out :\t%lf\t%lf\t%lf\n' % tuple(data_out)) else: errmsg = some_function(rv) print('error: %s\n' % errmsg) break

when running in interactive python prompt, comm_exchange updates data_out array each time expected (it'd work many times i'd try). however, when running script, updates data_out array once, connection error occurs @ sec phone call exchange. problem can't track downwards what's causing connection error in library, don't have source of library.

what i've tried: - filling data_in , data_out zeros, seemed unnecessary (printing them whilst running script showed zeros when did not explicitly that) - passing socket_id , info structures in different ways, without byref, using pointer , addressof. working code gave same result, no improvement. - garbage collection: tried switching off using gc.disable(), using global gcs. no effect noticed

any ideas on how tackle issue?

python 2.5.4, ctypes 1.0.3 (can't upgrade python because of other dependencies).

python dll ctypes

Comments

Popular posts from this blog

xslt - DocBook 5 to PDF transform failing with error: "fo:flow" is missing child elements. Required content model: marker* -

mediawiki - How do I insert tables inside infoboxes on Wikia pages? -

Local Service User Logged into Windows -