Unload extension modules when python22.dll unloads... [using C extension interpreter]

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Anand

    Unload extension modules when python22.dll unloads... [using C extension interpreter]

    I have a unexpected issue with python modules (well i kind of know
    why, but i am trying to find if there is a way around)

    Intro:
    I am allowing an external application to actually run python scripts.
    The external application i am taking about is a test sequencer with a
    lots of functionality. So the external application has a lot of gui
    and all the testing logic is done in python. Things work fine when i
    run regular code and i have been running python code successfully
    (several thousand lines of code) for over eight months.

    Issue:
    Well, now there is an requirement to throw a dialog box from
    python. I built a wxpython code and was able to successfully show the
    dialog box from python. But when i run the code for the second time,
    it wouldnt work..

    the wxpython's dll probably does some initialization during
    dll_process_att ach... but i never see the pyd get unloaded ( i
    actually unload python22.dll after each run). this is a big problem
    now. i did not really consider about this earlier. so i cannot
    actually Guarantee proper fuctioning of the python code...

    is there a way for me to *unload dynamically loaded extension module*
    each time and then reload it each time when the code is called...

    thanks a lot in advance.
  • Tim Daneliuk

    #2
    Re: Unload extension modules when python22.dll unloads... [usingC extension interpreter]

    Anand wrote:
    [color=blue]
    > I have a unexpected issue with python modules (well i kind of know
    > why, but i am trying to find if there is a way around)
    >
    > Intro:
    > I am allowing an external application to actually run python scripts.
    > The external application i am taking about is a test sequencer with a
    > lots of functionality. So the external application has a lot of gui
    > and all the testing logic is done in python. Things work fine when i
    > run regular code and i have been running python code successfully
    > (several thousand lines of code) for over eight months.
    >
    > Issue:
    > Well, now there is an requirement to throw a dialog box from
    > python. I built a wxpython code and was able to successfully show the
    > dialog box from python. But when i run the code for the second time,
    > it wouldnt work..
    >
    > the wxpython's dll probably does some initialization during
    > dll_process_att ach... but i never see the pyd get unloaded ( i
    > actually unload python22.dll after each run). this is a big problem
    > now. i did not really consider about this earlier. so i cannot
    > actually Guarantee proper fuctioning of the python code...
    >
    > is there a way for me to *unload dynamically loaded extension module*
    > each time and then reload it each time when the code is called...
    >
    > thanks a lot in advance.[/color]

    Another thought: If you are running on Win32, (iirc) there is a way to
    present a dialog box directly from a python script using win32all. This
    method, while not portable, has the advantage of not having to go
    through all the usual GUI gobbledy-gook to set up and process the dialog
    ....

    import win32gui

    retval = win32gui.Dialog Box(....)

    HTH,
    ----------------------------------------------------------------------------
    Tim Daneliuk tundra@tundrawa re.com
    PGP Key: http://www.tundraware.com/PGP/

    Comment

    • Anand

      #3
      Re: Unload extension modules when python22.dll unloads... [using C extension interpreter]

      Tim,
      thanks a lot for your suggestions. this is lot simpler than my
      wxpython approach.

      Thanks,
      Anand.

      Tim Daneliuk <tundra@tundraw are.com> wrote in message news:<dgfq71-1nk.ln1@eskimo. tundraware.com> ...[color=blue]
      > Another thought: If you are running on Win32, (iirc) there is a way to
      > present a dialog box directly from a python script using win32all. This
      > method, while not portable, has the advantage of not having to go
      > through all the usual GUI gobbledy-gook to set up and process the dialog
      > ...
      >
      > import win32gui
      >
      > retval = win32gui.Dialog Box(....)
      >
      > HTH,
      > ----------------------------------------------------------------------------
      > Tim Daneliuk tundra@tundrawa re.com
      > PGP Key: http://www.tundraware.com/PGP/[/color]

      Comment

      • Tim Daneliuk

        #4
        Re: Unload extension modules when python22.dll unloads... [usingC extension interpreter]

        Anand wrote:
        [color=blue]
        > Tim,
        > thanks a lot for your suggestions. this is lot simpler than my
        > wxpython approach.
        >
        > Thanks,
        > Anand.
        >
        > Tim Daneliuk <tundra@tundraw are.com> wrote in message news:<dgfq71-1nk.ln1@eskimo. tundraware.com> ...
        >[color=green]
        >>Another thought: If you are running on Win32, (iirc) there is a way to
        >>present a dialog box directly from a python script using win32all. This
        >>method, while not portable, has the advantage of not having to go
        >>through all the usual GUI gobbledy-gook to set up and process the dialog
        >>...
        >>
        >>import win32gui
        >>
        >>retval = win32gui.Dialog Box(....)
        >>
        >>HTH,[/color][/color]


        There is, of course, still _some_ fiddling around you have to do to setup
        the Box for native Win32 API calls ... I'd be interested in seeing a
        sample of the code when you get it working...

        The one downside of doing things this way (beyond the lack of portability)
        is that you do have to know the win32 apis well, which I do not. But it
        does seem to be a more quick-n-dirty approach than having to go through
        all the overhead of wxWin or Tkinter setup ...


        --
        ----------------------------------------------------------------------------
        Tim Daneliuk tundra@tundrawa re.com
        PGP Key: http://www.tundraware.com/PGP/

        Comment

        Working...