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

From Peter Otten <__peter__@web.de>
Newsgroups comp.lang.python
Subject Re: python response slow when running external DLL
Date 2015-11-27 10:18 +0100
Organization None
Message-ID <mailman.169.1448615930.20593.python-list@python.org> (permalink)
References <dc290806-c537-4546-b802-88dff14d81c0@googlegroups.com>

Show all headers | 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