Skip to content

Instantly share code, notes, and snippets.

@joar
Created June 12, 2019 12:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joar/f021db55eca4fa9e9fd7dfd67cc011b9 to your computer and use it in GitHub Desktop.
Save joar/f021db55eca4fa9e9fd7dfd67cc011b9 to your computer and use it in GitHub Desktop.
import logging
import apache_beam as beam
from apache_beam.options.pipeline_options import PipelineOptions, SetupOptions
_log = logging.getLogger(__name__)
def main(argv=None):
logging.basicConfig(level=logging.INFO)
pipeline_options = PipelineOptions(argv)
setup_options = pipeline_options.view_as(SetupOptions) # type: SetupOptions
setup_options.save_main_session = True
_log.info("Running pipeline")
with beam.Pipeline(runner="DirectRunner", options=pipeline_options) as p:
p | beam.Create(["hello", "world"]) | beam.Map(lambda x: print(x))
print("""
Call to _log.info will now deadlock, since the logging handler's
threading.RLock() has been passed through dill.
When you press Ctrl-C, the traceback should confirm that the process is
stuck at:
File "/usr/lib/python3.5/logging/__init__.py", line 810, in acquire
self.lock.acquire()
""")
_log.info("Pipeline done")
print("Launching nukes")
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment