spyder-ide / spyder-reports

Spyder plugin to render Markdown reports using Pweave as a backend
MIT License
70 stars 18 forks source link

Render is failling with latest Pweave #65

Open rlaverde opened 7 years ago

rlaverde commented 7 years ago

Render is failing with: signal only works in main thread after this pweave change: https://github.com/mpastell/Pweave/commit/3765b0ceebfc17be8e86b8a66d8e1eac1240096b

Error in atexit._run_exitfuncs:
Traceback (most recent call last):
  File "/home/rlaverde/anaconda3/envs/spyder/lib/python3.5/site-packages/IPython/core/history.py", line 780, in writeout_cache
    self._writeout_input_cache(conn)
  File "/home/rlaverde/anaconda3/envs/spyder/lib/python3.5/site-packages/IPython/core/history.py", line 764, in _writeout_input_cache
    (self.session_number,)+line)
sqlite3.ProgrammingError: SQLite objects created in a thread can only be used in that same thread.The object was created in thread id 140131990218496 and this is thread id 140134640838400
rlaverde commented 7 years ago

Maybe this is related: https://github.com/scrapy/scrapy/commit/8d77005047cc701970c8c4114a65423c0dc7c2ee

I think that WorkerManager is doing something with the workers that cause it the thread to change, or maybe is because it's use QThread

rlaverde commented 7 years ago

I've finally found the bug, It's caused because the workermanager change the worker thread in _start() method https://github.com/spyder-ide/spyder/blob/master/spyder/utils/workers.py#L264

Using instead the logic for ProcessWorker, fix the bug (although that doesn't seem as the best solution)

cc: @goanpeca

rlaverde commented 7 years ago

I think that the only solution is to move to use ProcessWorker, I'll further investigate if there is other solution before doing that.

goanpeca commented 7 years ago

@rlaverde moving forward with spyder handling envs, and other python versions, we will most likely rely on the LSP or the process worker since, the python worker only really makes sense for things that will be executed in the same environment that spyder lives. I know this is a different issue, but it is probably more reliable to do it using the process worker, although it might take a little more time (while a new python process is started). You can also have a helper script that runs PWeave and execute that script in a process if that makes things easier.