Comments you submit will be routed for moderation. If you have an account, please log in first.

Ticket #184 (new defect)

Opened 4 months ago

Last modified 12 days ago

Pyinstaller doesn't work properly with threading.Thread module

Reported by: jackson@jacksonc.com Owned by: giovannibajo
Priority: normal Milestone:
Component: PyInstaller Version: PyInstaller 1.4
Severity: blocker Keywords:
Cc:

Description

A program that scans wifi networks using the threading.Thread module doesn't work, so I stripped the program down until I found where execution wasn't as expected. And it seems that things go weird when they enter the threading.Thread.run() method. After building the following code...

import threading

class TestThreadClass(threading.Thread):
	def __init__(self):
		threading.Thread.__init__(self)

	def run(self):
		print 'ONE'
		print 'TWO'
		print 'THREE'

TestThreadClass().start()

When executed from the terminal in Ubuntu 10.04 and Python 2.6.5 it consistently prints "ONE\nTWO\nTHREE". But when built with PyInstaller? (latest SVN as of 7th May), if I run the program over and over I get different output every time.

eg...

jackson@jackson-laptop:~/Desktop/obscure-bug/dist/test-obscure-bug$ ./test-obscure-bug 
ONE

TWO
THREE
jackson@jackson-laptop:~/Desktop/obscure-bug/dist/test-obscure-bug$ ./test-obscure-bug 
jackson@jackson-laptop:~/Desktop/obscure-bug/dist/test-obscure-bug$ ./test-obscure-bug 
jackson@jackson-laptop:~/Desktop/obscure-bug/dist/test-obscure-bug$ ./test-obscure-bug 
ONEjackson@jackson-laptop:~/Desktop/obscure-bug/dist/test-obscure-bug$ ./test-obscure-bug 
ONE

TWO
jackson@jackson-laptop:~/Desktop/obscure-bug/dist/test-obscure-bug$ ./test-obscure-bug 
ONE

jackson@jackson-laptop:~/Desktop/obscure-bug/dist/test-obscure-bug$ ./test-obscure-bug 
jackson@jackson-laptop:~/Desktop/obscure-bug/dist/test-obscure-bug$ ./test-obscure-bug 
ONE

jackson@jackson-laptop:~/Desktop/obscure-bug/dist/test-obscure-bug$ ./test-obscure-bug 
ONE

TWO
jackson@jackson-laptop:~/Desktop/obscure-bug/dist/test-obscure-bug$ ./test-obscure-bug 
jackson@jackson-laptop:~/Desktop/obscure-bug/dist/test-obscure-bug$ 

Attachments

Change History

Changed 4 months ago by jkz88

Oh, and I tried replacing the statements with...

sys.stdout.write('ONE\n')
sys.stdout.flush()
sys.stdout.write('TWO\n')
sys.stdout.flush()
sys.stdout.write('THREE\n')
sys.stdout.flush()

so stdout's buffer continually gets flushed, but it doesn't make any difference.

Changed 12 days ago by giovannibajo

There must be something missing in the bootloader, in the cleanup process.

Workaround is to call thread.join() in your main.

Add/Change #184 (Pyinstaller doesn't work properly with threading.Thread module)

Author


E-mail address and user name can be saved in the Preferences.


Action
as new
 
Note: See TracTickets for help on using tickets.