Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #99630

Re: python response slow when running external DLL

Path csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail
From Peter Otten <__peter__@web.de>
Newsgroups comp.lang.python
Subject Re: python response slow when running external DLL
Date Fri, 27 Nov 2015 10:18:35 +0100
Organization None
Lines 62
Message-ID <mailman.169.1448615930.20593.python-list@python.org> (permalink)
References <dc290806-c537-4546-b802-88dff14d81c0@googlegroups.com>
Mime-Version 1.0
Content-Type text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding 7Bit
X-Trace news.uni-berlin.de AfXGJeYaGXYNQMMEYezBdwsHVxZriKuJrR3XVx1y+xKA==
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'else:': 0.03; 'exercise': 0.03; 'scripts': 0.09; 'follows.': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'stdout': 0.09; 'example:': 0.10; 'python.': 0.11; 'def': 0.13; 'subject:python': 0.14; '"test"': 0.16; 'deferred': 0.16; 'flush().': 0.16; 'received:80.91.229.3': 0.16; 'received:dip0.t-ipconnect.de': 0.16; 'received:io': 0.16; 'received:plane.gmane.org': 0.16; 'received:psf.io': 0.16; 'received:t-ipconnect.de': 0.16; 'result:': 0.16; 'subject:slow': 0.16; 'subject:when': 0.16; 'wrote:': 0.16; 'result,': 0.18; 'script.': 0.18; 'gui': 0.18; 'skip:" 30': 0.20; '%s"': 0.22; 'builder': 0.22; 'pass': 0.22; 'help.': 0.23; 'seems': 0.23; 'finished': 0.23; 'import': 0.24; 'written': 0.24; 'header:User- Agent:1': 0.26; 'header:X-Complaints-To:1': 0.26; 'rest': 0.26; 'skip:" 20': 0.26; 'external': 0.27; 'dll': 0.27; 'function': 0.28; 'behaviour': 0.29; 'writes': 0.30; 'seconds': 0.31; 'anyone': 0.32; 'ideal': 0.32; 'statement': 0.32; 'point': 0.33; 'skip:_ 30': 0.33; 'c++': 0.35; 'fail': 0.35; 'false': 0.35; 'replace': 0.35; 'something': 0.35; 'but': 0.36; 'possible.': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'received:org': 0.37; 'busy': 0.38; 'front': 0.38; 'skip:v 20': 0.38; 'skip:p 20': 0.38; 'end': 0.39; 'skip:- 20': 0.39; 'test': 0.39; 'does': 0.39; "didn't": 0.39; 'takes': 0.39; 'to:addr:python.org': 0.40; 'received:de': 0.40; 'your': 0.60; 'ago.': 0.61; 'show': 0.62; 'real': 0.62; 'strange': 0.63; 'more': 0.63; 'saw': 0.77; 'ini': 0.84; 'phenomenon': 0.84; 'remark': 0.84; 'subject:response': 0.91
X-Injected-Via-Gmane http://gmane.org/
X-Gmane-NNTP-Posting-Host p57bd9084.dip0.t-ipconnect.de
User-Agent KNode/4.13.3
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.20+
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Xref csiph.com comp.lang.python:99630

Show key headers only | View raw


jfong@ms4.hinet.net wrote:

> I am new to Python. As an exercise of it, I try to port a program which
> was written more than 10 years ago. This program use the Borland C++
> Builder as its GUI front end and a DLL does the real work(it will takes a
> few seconds to complete). I saw a strange phenomenon in the following
> codes. The "var_status.set('Download...')" statement seems was deferred
> and didn't show up until the external DLL job was finished and I can only
> saw the result of "var_status.set('Download OK')" statement which
> immediately follows. I try to do the DLL function in a thread(selected by
> using the "test" flag in codes), but it didn't help.
> 
> Can anyone tell me what's the point I was missed?

What does var_status.set() do? If it writes to stdout you may just need to 
flush().

Do you see the same behaviour when you replace mydll.SayHello() with 
something simple like time.sleep(1)?

> -------------------------
> def download():
>     global iniFilename
>     if test:  global result, busy
>     ini = iniFilename
>     iniFilename = "c:\\$$temp.in3"
>     saveIniFile()
>     iniFilename = ini
>     #do the rest
>     var_status.set('Download...')
>     if not test:
>         result = mydll.SayHello()
>     else:
>         busy = True
>         _thread.start_new_thread(td_download, ())
>         while busy:  pass
>     if result:
>         var_status.set("Download Fail at %s" % hex(result))
>         showerror('Romter', 'Download Fail')
>     else:
>         var_status.set('Download OK')
>         showinfo('Romter', 'Download OK')
> 
> if test:
> result = 0x5555
> busy = True
> def td_download():
>     global busy, result
>     result = mydll.SayHello()
>     busy = False
> --------------------------

As a general remark keep your test scripts as simple as possible. Example: 
If 

import mydll
print("Download...", end="")
mydll.SayHello()
print("OK")

showed the same behaviour it would be the ideal test script.

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

python response slow when running external DLL jfong@ms4.hinet.net - 2015-11-26 23:51 -0800
  Re: python response slow when running external DLL Peter Otten <__peter__@web.de> - 2015-11-27 10:18 +0100
    Re: python response slow when running external DLL jfong@ms4.hinet.net - 2015-11-27 03:14 -0800
      Re: python response slow when running external DLL Peter Otten <__peter__@web.de> - 2015-11-27 13:20 +0100
        Re: python response slow when running external DLL jfong@ms4.hinet.net - 2015-11-27 23:37 -0800
          Re: python response slow when running external DLL Peter Otten <__peter__@web.de> - 2015-11-28 11:13 +0100
            Re: python response slow when running external DLL jfong@ms4.hinet.net - 2015-11-28 18:55 -0800
              Re: python response slow when running external DLL jfong@ms4.hinet.net - 2015-11-30 17:03 -0800
              Re: python response slow when running external DLL Peter Otten <__peter__@web.de> - 2015-12-01 12:01 +0100
                Re: python response slow when running external DLL jfong@ms4.hinet.net - 2015-12-01 19:58 -0800
          Re: python response slow when running external DLL Laura Creighton <lac@openend.se> - 2015-11-28 11:51 +0100
            Re: python response slow when running external DLL jfong@ms4.hinet.net - 2015-11-28 19:04 -0800
      Re: python response slow when running external DLL Laura Creighton <lac@openend.se> - 2015-11-27 13:49 +0100

csiph-web