Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ class ElementData(object):
Stores information created by a FlowElement based on FlowData.
Stored in FlowData

Only the Flow Element that creates an instance writes it, so an instance
does not need to be safe to write from several threads. A finished
instance, once the Flow Element that writes it has finished, is safe to
read from several threads at once, such as the caller's own threads. An
instance that is written from several threads, or read while another
thread writes it, is not catered for.

"""

def __init__(self, flow_element):
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@

"""
The documentation of Element Data says it is safe to read from several threads
once the Flow Element that writes it has finished, and is not catered for when
written from several threads or read while another thread writes, as the
thread safety page of the specification requires.
"""

import unittest

from fiftyone_pipeline_core.elementdata import ElementData


class ElementDataDocumentationTests(unittest.TestCase):

def test_the_documentation_says_what_is_safe_with_threads(self):
text = " ".join(ElementData.__doc__.split())
self.assertIn("safe to read from several threads", text)
self.assertIn("once the Flow Element that writes it has finished", text)
self.assertIn("not catered for", text)
self.assertIn("written from several threads", text)
self.assertIn("read while another thread writes", text)


if __name__ == "__main__":
unittest.main()
Loading