[python-win32] dde.pyd always dies after exactly 16378 Requests
Ray Schumacher
rays at blue-cove.com
Thu May 26 19:51:05 CEST 2005
In the attached .py test, I start an external program that provides data access via DDE.
create a server
do a number of CreateConversation-s, one for each channel
make connections
do lots of .Request on the connections
I tried just one channel, one connection, still 16378, so it seems to be the total number of requests, irrespective of connections/Conversations.
Do I need to periodically clean up resources somehow?
The docs at Activestate are a bit sparse, and I could not find the answer from MSDN.com:
"The maximum number of DDE conversations that can be open simultaneously is determined by Microsoft Windows and your computer's memory and resources. If the conversation can't be initiated because application isn't running or doesn't recognize topic, or if the maximum number of conversations has already been reached, the DDE function returns a Null. "
But, conversations is not the issue.
Am I doing DDE in a fundamentally inefficient manner?
Would using 'CreateServerSystemTopic', 'CreateStringItem', 'CreateTopic' help at all?
When I run this script (or similar, counting requests), it always ends up like this:
C:\python ddeclient_tst.py
...
16362 same
16363
16364
16365
16366
16367
16368
16369
16370
16371 same
16372
16373
16374
16375
16376
16377
16378 <---- dies here with Windows error
>> C:\
I could shut down the server and reconnect it all, but that takes significant time.
Thanks,
Ray
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/python-win32/attachments/20050526/9f583409/attachment-0001.htm
-------------- next part --------------
import os, sys
import win32ui
import dde
import win32api
import win32process
import time
pathpy = 'C:/Program Files/PRO 4.0/'
oldPath = os.getcwd( )
os.chdir(pathpy)
STARTUPINFO=win32process.STARTUPINFO()
execute_target=pathpy+'prog.exe'
commandLine=None
processAttributes=None
threadAttributes=None
bInheritHandles=0
dwCreationFlags=win32process.NORMAL_PRIORITY_CLASS
newEnvironment=None
processHndl, primary_thread, pid, tid = win32process.CreateProcess(execute_target,
commandLine,
processAttributes,
threadAttributes,
bInheritHandles,
dwCreationFlags,
newEnvironment,
os.getcwd( ),
STARTUPINFO)
time.sleep(6)
print 'start', processHndl, primary_thread
os.chdir(oldPath)
server = dde.CreateServer()
server.Create("Py")
channels = 4
## make a list of pre-connected conversations
## 0 is STATUS
## 1 is COMMAND
## 2-8 are channels
ddeConvList = []
for c in range(2+channels*2):
ddeConvList.append(dde.CreateConversation(server))
ddeConvList[0].ConnectTo("CV90", "STATUS")
ddeConvList[1].ConnectTo("CV90", "COMMAND")
for chnl in range(2, 2+channels):
ddeConvList[chnl].ConnectTo("CV90", "CHANNEL_"+str(chnl))
try: ddeConvList[1].Exec("LOAD CNFG C:\\GenIM.cfg")
except: pass
time.sleep(3)
ddeConvList[1].Exec("CTRL WATR START")
start = time.time()-.00001
caught = 0
reqs = 0
lastreq = ''
while caught<20000 and time.time()<start+300:
answer = ''
for chnl in range(2, 2+channels):
reqs += 1
print reqs
answer += ddeConvList[chnl].Request("1XMAG")[:8]
reqs += 1
print reqs
answer += ' '+ddeConvList[chnl].Request("1XPHASE")[:8]
reqs += 1
print reqs
ddeConvList[0].Request("RPM")[:8]
if answer!=lastreq:
print reqs, 'tot.', caught, caught/(time.time()-start), '/second'
lastreq = answer
caught += 1
else:
print 'same'
time.sleep(.001)
server.Shutdown()
-------------- next part --------------
A non-text attachment was scrubbed...
Name: errorcontents.jpg
Type: image/jpeg
Size: 9177 bytes
Desc: not available
Url : http://mail.python.org/pipermail/python-win32/attachments/20050526/9f583409/errorcontents-0001.jpg
-------------- next part --------------
A non-text attachment was scrubbed...
Name: error2.jpg
Type: image/jpeg
Size: 7012 bytes
Desc: not available
Url : http://mail.python.org/pipermail/python-win32/attachments/20050526/9f583409/error2-0001.jpg
More information about the Python-win32
mailing list