MCPcopy
hub / github.com/ray-project/ray / get_serialization_context

Method get_serialization_context

python/ray/_private/worker.py:755–775  ·  view source on GitHub ↗

Get the SerializationContext of the job that this worker is processing. Returns: The serialization context of the given job.

(self)

Source from the content-addressed store, hash-verified

753 return 0
754
755 def get_serialization_context(self):
756 """Get the SerializationContext of the job that this worker is processing.
757
758 Returns:
759 The serialization context of the given job.
760 """
761 # This function needs to be protected by a lock, because it will be
762 # called by`register_class_for_serialization`, as well as the import
763 # thread, from different threads. Also, this function will recursively
764 # call itself, so we use RLock here.
765 job_id = self.current_job_id
766 context_map = self.serialization_context_map
767 with self.lock:
768 if job_id not in context_map:
769 # The job ID is nil before initializing Ray.
770 if JobID.nil() in context_map:
771 # Transfer the serializer context used before initializing Ray.
772 context_map[job_id] = context_map.pop(JobID.nil())
773 else:
774 context_map[job_id] = serialization.SerializationContext(self)
775 return context_map[job_id]
776
777 def check_connected(self):
778 """Check if the worker is connected.

Calls 2

nilMethod · 0.45
popMethod · 0.45