Forum

Author Topic: Console output message order doesn't match order of execution  (Read 1479 times)

w28

  • Newbie
  • *
  • Posts: 11
    • View Profile
I ran into some unexpected behavior from the console which tripped me up for a bit.  I don't think it's big deal, but I'm posting here in case it potentially saves someone else the hassle of troubleshooting it. 

The order of messages output by the Photoscan python console doesn't necessarily match the order of the commands being executed.  For instance:

Code: [Select]
print('CHUNK WILL BE COPIED --AFTER-- THIS PRINT STATEMENT')
newchunk = chunk.copy()
newchunk.label = chunk.label + '_NewChunk'

2018-05-24 16:47:26 DuplicateChunk: items = (depth maps, dense cloud, model, DEM, orthomosaic, tiled model)
2018-05-24 16:47:26 Duplicating chunk...
2018-05-24 16:47:26 Finished processing in 0.016 sec (exit code 1)
2018-05-24 16:47:26 CHUNK WILL BE COPIED --AFTER-- THIS PRINT STATEMENT

I even paused the copy() method by inserting a time.sleep() line, but it didn't change the outcome:
Code: [Select]
import time
print('CHUNK WILL BE COPIED --AFTER-- THIS PRINT STATEMENT')
time.sleep(5)
newchunk = chunk.copy()
newchunk.label = chunk.label + '_NewChunk'

2018-05-24 16:47:54 DuplicateChunk: items = (depth maps, dense cloud, model, DEM, orthomosaic, tiled model)
2018-05-24 16:47:54 Duplicating chunk...
2018-05-24 16:47:54 CHUNK WILL BE COPIED --AFTER-- THIS PRINT STATEMENT
2018-05-24 16:47:54 Finished processing in 0.031 sec (exit code 1)


Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14813
    • View Profile
Re: Console output message order doesn't match order of execution
« Reply #1 on: June 11, 2018, 08:32:22 PM »
Hello w28,

I suggest the following:
Code: [Select]
import time
from PySide2 import QtWidgets
app = QtWidgets.QApplication.instance()
print('CHUNK WILL BE COPIED --AFTER-- THIS PRINT STATEMENT')
time.sleep(0.5)
app.processEvents()
newchunk = chunk.copy()
newchunk.label = chunk.label + '_NewChunk'
processEvent() will update the application window and the print statement will be treated in proper time.
Best regards,
Alexey Pasumansky,
Agisoft LLC