473,396 Members | 1,599 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

weird COM hazard

mic
I'm getting strange hazard while running MSIE automation script. This
concerns MSIE events, especially OnDownloadBegin and OnClosing but I bet
they're not the only ones. The simplified code looks like this:

from win32com.client import DispatchWithEvents

class ConnectionStatus: #this is 'static' class containing most of the
parameters needed from other parts of the script
MainBusy = False
ChildBusy = False

class MSIE:
Main = DispatchWithEvents('InternetExplorer.Application', MainEvents)
Child = DispatchWithEvents('InternetExplorer.Application', ChildEvents)
"""
then I do some browsing on 'Main' here, especially to the page that
fires using JavaScript new window,
that's being captured by Child object. Then the Child window is closed
by using JS window.close()
"""

class MainEvents:
def OnDownloadBegin(self):
ConnectionStatus.MainBusy = True

def OnDocumentComplete(self):
ConnectionStatus.MainBusy = True
"""
this way I catch most of the available events. The only operation I do is
set the ConnectionStatus class attributes
The same goes to ChildEvents:
"""
class ChildEvents:
def OnDownloadBegin(self):
ConnectionStatus.ChildBusy = True

def OnDocumentComplete(self):
ConnectionStatus.ChildBusy = True

The problem is that from time to time some of the child events raises
exception:

AttributeError: 'NoneType' object has no attribute 'ChildBusy'

and after a short debugging it looks like at some moment I loose the
reference to the ConnectionStatus class, though obviously I make no such
operation at all. As it happens 50% of times I run the same script and seems
to stop not only at the same event, I'm starting to believe that this is
kind of a bug in win32com. Does anybody experienced anything like that?

Thanks in advance,

Michal
Jul 18 '05 #1
2 1262
mic wrote:
and after a short debugging it looks like at some moment I loose the
reference to the ConnectionStatus class, though obviously I make no such
operation at all. As it happens 50% of times I run the same script and seems
to stop not only at the same event, I'm starting to believe that this is
kind of a bug in win32com. Does anybody experienced anything like that?


What environment is this being run in? The only way I could see this
being set to None externally is if Python itself is in the process of
shutting down. There is nothing in win32com that will prevent Python
terminating while COM objects are alive, so there is the potential that
an external program tries to call back into Python during shutdown. I
can't see how this could happen using Python.exe though.

It is certainly nothing that has been reported before.

Mark.

Jul 18 '05 #2
mic
I've found the walkaround by setting within the child event class

constructor the local attribute that's equal to the external status class. I

can then reach the status without previously mentioned, random exceptions.

Strange, but works ok. Now I'm just investigating why my COM proxy object

returns at first string 'Microsoft Internet Explorer' and after a while:

win32com.client.COMEventClass. Does anyone know why?
Jul 18 '05 #3

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

Similar topics

9
by: Radium | last post by:
Cascading Style Sheet is an extreme hazard to your privacy. It allows others on the internet to see your monitor and files. It allows them to copy images on your monitor to their computers. It...
5
by: Radium | last post by:
Cascading Style Sheet is such a hazard to your privacy. It allows others on the internet to see your monitor and files. It allows them to copy images on your monitor to their computers. It also...
7
by: Green Xenon [Radium] | last post by:
Cascading Style Sheet is such a hazard to your privacy. It allows others on the internet to see your monitor and files. It allows them to copy images on your monitor to their computers. It also...
7
by: Green Xenon [Radium] | last post by:
Cascading Style Sheet is such a hazard to your privacy. It allows others on the internet to see your monitor and files. It allows them to copy images on your monitor to their computers. It also...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.