473,657 Members | 2,593 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Python COM - limit on size/complexity of returned object?

I have a very simple COM server written in Python that is trying to
return a two-dimensional array 268 x 20. The values it contains are
some small integers, some short (<29 character) Unicode strings, and
None.

To isolate the problem I have taken out the code that builds the
matrix from real data, and just substituted a literal tuple of tuples,
like this:

class AtlasSecurity:
_reg_progid_ = 'Arena.Security '
...
def GetProfileCompo nentMatrixEx(se lf):
# self.BuildMatri x()
self.matrix = ((u'ID', u'Name', u'Type', .... ),
... )) # a 268-tuple of 20-tuples
self.last_resul t = (self.matrix,)
return self.last_resul t

Because I was having trouble calling it from Excel ("the server has
disconnected from its clients"), to see what was going on I decided to
call it from a Python client, like this:

from win32com.client import Dispatch
x = Dispatch("Arena .Security")
print x.GetProfileCom ponentMatrixEx( )

This blows up in python22.dll with a C++ Runtime abort(), no matter
what I try. I can write a method that I can call 268 times to return
the data one 20-element vector at a time. This works, but is really
only good for simple data structures and I need this to work with
structures of arbitrary complexity and levels of nesting.

Is there a restriction on the size or complexity of the SafeArray that
pythoncom is constructing from the returned value? Or what else am I
doing wrong?

(I am using Python 2.2 because I am working with embedded Python and
that is the version that is embedded.)
Jul 18 '05 #1
3 1961
Hi !

Only for size (because I don't understand correctly english).

I had a COM-server, in Python. And I send/read string of 5-10MB size,
without pb (perhaps time had few seconds in excess).

@-salutations
--
Michel Claveau
mél : http://cerbermail.com/?6J1TthIa8B
sites : http://mclaveau.com http://bergoiata.org http://ponx.org

Jul 18 '05 #2
go****@prodigyc omputing.com (Paul Keating) wrote in message news:<51******* *************** ****@posting.go ogle.com>...
I have a very simple COM server written in Python that is trying to
return a two-dimensional array 268 x 20. The values it contains are
some small integers, some short (<29 character) Unicode strings, and
None.

To isolate the problem I have taken out the code that builds the
matrix from real data, and just substituted a literal tuple of tuples,
like this:

class AtlasSecurity:
_reg_progid_ = 'Arena.Security '
...
def GetProfileCompo nentMatrixEx(se lf):
# self.BuildMatri x()
self.matrix = ((u'ID', u'Name', u'Type', .... ),
... )) # a 268-tuple of 20-tuples
self.last_resul t = (self.matrix,)
return self.last_resul t

Because I was having trouble calling it from Excel ("the server has
disconnected from its clients"), to see what was going on I decided to
call it from a Python client, like this:

from win32com.client import Dispatch
x = Dispatch("Arena .Security")
print x.GetProfileCom ponentMatrixEx( )

This blows up in python22.dll with a C++ Runtime abort(), no matter
what I try. I can write a method that I can call 268 times to return
the data one 20-element vector at a time. This works, but is really
only good for simple data structures and I need this to work with
structures of arbitrary complexity and levels of nesting.

Is there a restriction on the size or complexity of the SafeArray that
pythoncom is constructing from the returned value? Or what else am I
doing wrong?

(I am using Python 2.2 because I am working with embedded Python and
that is the version that is embedded.)


Well, I did some testing with python 2.3 (that's what I have).
Not sure if it will cheer you up, but I had no problems.

- kv
<server-code>
class AtlasSecurity:
_reg_clsid_ = '{92522CC6-05A5-4172-BFCA-56C65FD45467}'
_reg_desc_ = 'Arena Server'
_reg_progid_ = 'Arena.Security '

_public_methods _ = ['GetProfileComp onentMatrixEx']
_public_attrs_ = []
_readonly_attrs _ = []

def GetProfileCompo nentMatrixEx(se lf):
self.matrix = ((u'ID', u'Name', u'Type') * 10,) * 268
self.last_resul t = (self.matrix,)
return self.last_resul t
if __name__ == '__main__':
import win32com.server .register
win32com.server .register.UseCo mmandLine(Atlas Security)
</server-code>
<python-client-code>
import win32com.client

from win32com.client import Dispatch
x = Dispatch("Arena .Security")
print x.GetProfileCom ponentMatrixEx( )
</python-client-code>

<vb-client-code>
Dim A As Object
Set A = CreateObject("A rena.Security")

Dim V As Variant
Let V = A.GetProfileCom ponentMatrixEx( )
</vb-client-code>
Jul 18 '05 #3
kv***********@y ahoo.com (Konstantin Veretennicov) wrote in message news:<51******* *************** ****@posting.go ogle.com>...
Well, I did some testing with python 2.3 (that's what I have).
Not sure if it will cheer you up, but I had no problems.


Thanks for the pointer. I tried it on another machine with 2.3 and
that works with no problems.

And I made some further discoveries on the 2.2 side: the problem isn't
a limit on the size of the returned object, it's cumulative. I amended
GetProfileCompo nentMatrixEx() to return the first n rows of the
matrix, to find out what the limit was: like this
print len(GetProfileC omponentMatrixE x(10)) 10 print len(GetProfileC omponentMatrixE x(40)) 40 print len(GetProfileC omponentMatrixE x(80)) <GPF!>
But trying it repeatedly I found that I could only execute the
following line once: it crashed calling it with an argument of 40 the
second time: print len(GetProfileC omponentMatrixE x(40)) 40 print len(GetProfileC omponentMatrixE x(40)) <GPF!>
And then I tried this repeatedly: print len(GetProfileC omponentMatrixE x(10))

and -- surprise! -- it failed about the 7th or 8th invocation.

So, now there are two possibilities.
1. It's a 2.2 problem that is fixed in 2.3 (though I looked in
Sourceforge for the bug reports and this did not show up there).
2. It's a side-effect of the module I'm importing to do the actual
work. On the machine running 2.3, I had to write a stub to represent
this module, because it is a home machine that can't see the work
server where the data is.

If the DLL is at fault, I'm going to have a hard time convincing the
vendor that they have to fix it. If I were them, I'd be sceptical. The
DLL is loaded by the import statement, but in this test it is never
called. It's hard to see what it's initialization code could possibly
be doing to break pythoncom.
Jul 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
35524
by: Allison Bailey | last post by:
Hi Folks, I'm a brand new Python programmer, so please point me in the right direction if this is not the best forum for this question.... I would like to open an existing MS Excel spreadsheet and extract information from specific worksheets and cells. I'm not really sure how to get started with this process. I ran the COM Makepy utility from my PythonWin (IDE from ActiveSTate),
699
33863
by: mike420 | last post by:
I think everyone who used Python will agree that its syntax is the best thing going for it. It is very readable and easy for everyone to learn. But, Python does not a have very good macro capabilities, unfortunately. I'd like to know if it may be possible to add a powerful macro system to Python, while keeping its amazing syntax, and if it could be possible to add Pythonistic syntax to Lisp or Scheme, while keeping all of the...
65
5504
by: Amol Vaidya | last post by:
Hi. I am interested in learning a new programming language, and have been debating whether to learn Ruby or Python. How do these compare and contrast with one another, and what advantages does one language provide over the other? I would like to consider as many opinions as I can on this matter before I start studying either language in depth. Any help/comments are greatly appreciated. Thanks in advance for your help.
267
10676
by: Xah Lee | last post by:
Python, Lambda, and Guido van Rossum Xah Lee, 2006-05-05 In this post, i'd like to deconstruct one of Guido's recent blog about lambda in Python. In Guido's blog written in 2006-02-10 at http://www.artima.com/weblogs/viewpost.jsp?thread=147358
17
8465
by: frederic.pica | last post by:
Greets, I've some troubles getting my memory freed by python, how can I force it to release the memory ? I've tried del and gc.collect() with no success. Here is a code sample, parsing an XML file under linux python 2.4 (same problem with windows 2.5, tried with the first example) : #Python interpreter memory usage : 1.1 Mb private, 1.4 Mb shared #Using http://www.pixelbeat.org/scripts/ps_mem.py to get memory information
0
8385
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8821
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8502
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6162
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5632
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4150
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4300
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2726
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1941
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.