{"record":{"id":"cea16661d357b897","repo":"apache/beam","slug":"is-tornado-coroutine-is-deprecated-in-cloudpickle-3-0-and","errorCode":null,"errorMessage":"is_tornado_coroutine is deprecated in cloudpickle 3.0 and will be removed in cloudpickle 4.0. Use tornado.gen.is_coroutine_function directly instead.","messagePattern":"is_tornado_coroutine is deprecated in cloudpickle 3\\.0 and will be removed in cloudpickle 4\\.0\\. Use tornado\\.gen\\.is_coroutine_function directly instead\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"info","filePath":"sdks/python/apache_beam/internal/cloudpickle/cloudpickle.py","lineNumber":551,"sourceCode":"  to_remove = []\n  for name, value in clsdict.items():\n    try:\n      base_value = inherited_dict[name]\n      if value is base_value:\n        to_remove.append(name)\n    except KeyError:\n      pass\n  for name in to_remove:\n    clsdict.pop(name)\n  return clsdict\n\n\ndef is_tornado_coroutine(func):\n  \"\"\"Return whether `func` is a Tornado coroutine function.\n\n    Running coroutines are not supported.\n    \"\"\"\n  warnings.warn(\n      \"is_tornado_coroutine is deprecated in cloudpickle 3.0 and will be \"\n      \"removed in cloudpickle 4.0. Use tornado.gen.is_coroutine_function \"\n      \"directly instead.\",\n      category=DeprecationWarning,\n  )\n  if \"tornado.gen\" not in sys.modules:\n    return False\n  gen = sys.modules[\"tornado.gen\"]\n  if not hasattr(gen, \"is_coroutine_function\"):\n    # Tornado version is too old\n    return False\n  return gen.is_coroutine_function(func)\n\n\ndef subimport(name):\n  # We cannot do simply: `return __import__(name)`: Indeed, if ``name`` is\n  # the name of a submodule, __import__ will return the top-level root module\n  # of this submodule. For instance, __import__('os.path') returns the `os`","sourceCodeStart":533,"sourceCodeEnd":569,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/internal/cloudpickle/cloudpickle.py#L533-L569","documentation":"Beam's vendored cloudpickle copy emits a DeprecationWarning when is_tornado_coroutine is called: the helper is deprecated in cloudpickle 3.0 and will be removed in 4.0; callers should use tornado.gen.is_coroutine_function directly. It still works, returning whether the function is a Tornado coroutine.","triggerScenarios":"Cloudpickling Tornado coroutine functions (e.g. Tornado-based I/O callbacks inside a Beam pipeline) with cloudpickle 3.x, which invokes the deprecated helper during pickle dispatch.","commonSituations":"Pipelines that serialize Tornado coroutines or tornado.gen-based callables; upgrading cloudpickle from 2.x to 3.x and suddenly seeing DeprecationWarnings in worker logs.","solutions":["No action required — Beam vendors its own cloudpickle and will update before 4.0.","If the warning is noisy, filter it: warnings.filterwarnings('ignore', category=DeprecationWarning, module='apache_beam.internal.cloudpickle').","In your own code, replace calls to is_tornado_coroutine with tornado.gen.is_coroutine_function.","Avoid pickling raw Tornado coroutines in DoFns; pass plain functions or instantiate inside the DoFn."],"exampleFix":"# before\nimport apache_beam.internal.cloudpickle.cloudpickle as cp\nis_coro = cp.is_tornado_coroutine(func)\n# after\nimport tornado.gen\nis_coro = tornado.gen.is_coroutine_function(func)","handlingStrategy":"fallback","validationCode":"import sys, warnings\ndeprecated = 'apache_beam.internal.cloudpickle' in getattr(warnings, '__warningregistry__', {}) or 'tornado.gen' in sys.modules\n# prefer direct API:\nimport tornado.gen\ncoro = tornado.gen.is_coroutine_function(func) if 'tornado.gen' in sys.modules else False","typeGuard":"def is_tornado_coroutine_safe(func) -> bool:\n  import sys\n  if 'tornado.gen' not in sys.modules:\n    return False\n  import tornado.gen\n  return tornado.gen.is_coroutine_function(func)","tryCatchPattern":"import warnings\nwith warnings.catch_warnings():\n    warnings.filterwarnings('ignore', category=DeprecationWarning,\n                            module='apache_beam.internal.cloudpickle')\n    result = do_pickle(func)","preventionTips":["Never call Beam's vendored is_tornado_coroutine in user code; use tornado.gen.is_coroutine_function.","Avoid pickling Tornado coroutine objects inside DoFns.","Filter DeprecationWarnings from vendored modules in production logging configs.","Track Beam releases so vendored cloudpickle updates are picked up before cloudpickle 4.0."],"tags":["python","deprecation","cloudpickle","tornado","beam"],"backgroundTag":"deprecated-api-usage","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-20T03:17:13.778Z"}