(pywin related) pywintypes.com_error: -2147417846 "Application busy"

Discussion in 'Python' started by Alexander Eisenhuth, Nov 25, 2009.

  1. Hello list,

    I'm having a problem with a python COM Excel client that rarely gets the
    exception pywintypes.com_error with the error code -2147417846. (means Excel is
    busy) Here the python code of the exception handling:

    [...]
    try:
    # write a excel cell
    [...]
    except pywintypes.com_error, ex:
    if ex[0] == -2147417846:
    time.sleep(1.0)
    # retry write?
    [...]

    My first approach was to retry the writing to the excel cell. But that ends in a
    hanging Excel application (probably a deadlock).

    After a little research I found this post:

    http://social.msdn.microsoft.com/Forums/en-US/vsto/thread/70ef972b-51b6-4ece-a4af-d6b4e111eea5

    "[...] If you don't register a MessageFilter yourself (by calling
    CoRegisterMessageFilter), you will get default behavior which will be to fail
    the call if it gets rejected. .Net converts the failure HRESULT to an
    exception. To deal with the possibility of the server being busy when you try
    to call, you need to implement IMessageFilter::RetryRejectedCall in your client
    code and also register the message filter. In most cases, you will just need to
    wait for a few seconds and then retry the call--generally that will be
    sufficient time to enable Word to finish whatever it is doing so it can handle
    your call. However, if the instance of Word that you are controlling could
    possibly visible, you might want to add additional logic to display the
    OLEUIBUSY dialog after some amount of time has passed to notify the user that
    you are waiting on Word to do something and give them the opportunity to help
    the process. For example, as Misha mentions, Word will reject all incoming
    calls if a modal dialog box is up. Therefore, in that situation, you would be
    blocked indefinitely until the dialog is dismissed. [...]"

    As this part of the COM API (IMessageFilter, CoRegisterMessageFilter) isn't
    included in pywin32 I don't see a possibility to do that, or?

    Did anybody else have to deal with that problem?

    Any hints are very welcome.

    Regards
    Alexander
    Alexander Eisenhuth, Nov 25, 2009
    #1
    1. Advertising

  2. Hi!

    Your computer is too slow, for launch Excel.
    Configure the machine for more speed...

    @+
    --
    MCI
    Michel Claveau - MVP, Nov 25, 2009
    #2
    1. Advertising

  3. Re: (pywin related) pywintypes.com_error: -2147417846 "Applicationbusy"

    I don't think so, because it happens very rarely

    Michel Claveau - MVP schrieb:
    > Hi!
    >
    > Your computer is too slow, for launch Excel.
    > Configure the machine for more speed...
    >
    > @+
    Alexander Eisenhuth, Nov 25, 2009
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. x-herbert
    Replies:
    2
    Views:
    1,844
    x-herbert
    Aug 8, 2003
  2. Matt Smith
    Replies:
    1
    Views:
    6,204
    Mark Hammond
    Aug 9, 2003
  3. The Jetman
    Replies:
    0
    Views:
    427
    The Jetman
    Jul 27, 2004
  4. Lucas Machado

    handling pywintypes.error exceptions

    Lucas Machado, Mar 5, 2005, in forum: Python
    Replies:
    1
    Views:
    3,637
    Roger Upole
    Mar 5, 2005
  5. Replies:
    8
    Views:
    967
Loading...

Share This Page