Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QGIS crashes when printing to console in separate thread #28378

Closed
qgib opened this issue Nov 20, 2018 · 5 comments
Closed

QGIS crashes when printing to console in separate thread #28378

qgib opened this issue Nov 20, 2018 · 5 comments
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! Crash/Data Corruption High Priority PyQGIS Related to the PyQGIS API

Comments

@qgib
Copy link
Contributor

qgib commented Nov 20, 2018

Author Name: Matthew Jackson (Matthew Jackson)
Original Redmine Issue: 20558
Affected QGIS version: 3.4.1
Redmine category:python_bindings_/_sipify


If you run the following in the python console from QGIS 3.x in Windows 10, QGIS will crash every time. I believe this is a regression that began with 3.0, but I no longer have a 2.x version to compare with.

class PrintThread (QThread):
completed = pyqtSignal()
def init(self ):
QThread.init(self)
def run (self):
print("a message!")

t = PrintThread()
t.start()

@qgib
Copy link
Contributor Author

qgib commented Nov 20, 2018

Author Name: Giovanni Manghi (@gioman)


  • category_id was changed from Python plugins to Python bindings / sipify

@qgib
Copy link
Contributor Author

qgib commented Nov 20, 2018

Author Name: Alessandro Pasotti (@elpaso)


I think this is a won't fix: python printing from a thread will crash for sure.

You should use QgsMessageLog or other means to communicate with the user.

@qgib
Copy link
Contributor Author

qgib commented Nov 20, 2018

Author Name: Nyall Dawson (@nyalldawson)


It's not a regression - this has always been the case.


  • regression was changed from 1 to 0

@qgib
Copy link
Contributor Author

qgib commented Nov 22, 2018

Author Name: Juan Manuel Perez (@juanmpd)


Just tried the above code on QGis 2.18.20, and in 2.18 this piece of code didn't cause QGis to crash.
I stumbled on this issue while migrating a processing pluging from Qgis 2.18 to Qgis 3.4. Its processing algorithm included some 'print' statements, and I've been forced to remove them for Qgis3 (in Qgis2 they didn't cause any problems).

@qgib
Copy link
Contributor Author

qgib commented Nov 22, 2018

Author Name: Alessandro Pasotti (@elpaso)


The solution is simple: do not use "print" in a python script in QGIS.


  • resolution was changed from to wontfix
  • status_id was changed from Open to Closed

@qgib qgib closed this as completed Nov 22, 2018
@qgib qgib added Bug Either a bug report, or a bug fix. Let's hope for the latter! High Priority PyQGIS Related to the PyQGIS API Crash/Data Corruption labels May 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! Crash/Data Corruption High Priority PyQGIS Related to the PyQGIS API
Projects
None yet
Development

No branches or pull requests

1 participant