You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm getting occasional not reproducable errors (with the same markdown source) when running on Appengine:
Traceback (most recent call last):
[...]
File "/base/data/home/apps/.../deps/markdown/__init__.py", line 375, in convert
newRoot = treeprocessor.run(root)
File "/base/data/home/apps/.../deps/markdown/treeprocessors.py", line 330, in run
self.ancestors.pop()
IndexError: pop from empty list
I'm having threading enabled (GAE default), and TreeProcessor has a global ancestors stack. So presumably this crashes because simultaneous threads run the markdown processor. I can't find anything in the docs whether python-markdown is supposed to be thread safe, so thats either a documentation request or a bug ;-)
Are running multiple threads on a single instance of the Markdown class? Or a separate instance in a separate thread? It is kind of unclear on what exactly you are doing.
With that said, there has been no effort to guarantee thread safety, especially when you consider that you can pull in any custom extension which may or may not also be thread safe.
Personally, I would not rely on Python Markdown being thread safe.
We have never put any work into testing or verifying if Python-Markdown is thread safe. Personally I have no idea if it is or not.
Curious, how are you calling Markdown? Do you call the markdown.markdown wrapper which creates a new class instance on each call, or are you creating a single class instance and then calling convert for each request? I would expect the former to be more thread safe than the later.
Activity
facelessuser commentedon Apr 5, 2019
Are running multiple threads on a single instance of the Markdown class? Or a separate instance in a separate thread? It is kind of unclear on what exactly you are doing.
With that said, there has been no effort to guarantee thread safety, especially when you consider that you can pull in any custom extension which may or may not also be thread safe.
Personally, I would not rely on Python Markdown being thread safe.
waylan commentedon Apr 5, 2019
We have never put any work into testing or verifying if Python-Markdown is thread safe. Personally I have no idea if it is or not.
Curious, how are you calling Markdown? Do you call the
markdown.markdownwrapper which creates a new class instance on each call, or are you creating a single class instance and then callingconvertfor each request? I would expect the former to be more thread safe than the later.vbraun commentedon Apr 8, 2019
Indeed, I have a Markdown singleton (with some custom extensions) that all threads access.
So to summarize:
waylan commentedon Apr 8, 2019
That is correct. I suppose we should document that.
Document thread safety.
Document thread safety (#882)