Error while creating actor class

  • High: It blocks me to complete my task.

Getting error while creating instance of actor class.
Error:

ValueError: callable gi.FunctionInfo(signal_handler_disconnect) is not supported by signature

You can reproduce error with following block of code:

import gi
import ray

gi.require_version('Gst', '1.0')
gi.require_version('GstRtspServer', '1.0')
from gi.repository import Gst, GstRtspServer, GLib

@ray.remote
class GstServer(GstRtspServer.RTSPServer):
    def __init__(self, **properties):
        Gst.init(None)
        super(GstServer, self).__init__(**properties)
        self.loop = GLib.MainLoop()
        
    def start_streaming(self):
        self.loop.run()
        
    def stop_streaming(self):
        self.loop.quit()

if __name__ == "__main__":
	obj = GstServer.remote()
	obj.start_streaming()

Notes:

  • It’s running without ray actor conversion.

How can I install gi?

You can follow this:

I successfully installed gi but I was not able to run your script

Traceback (most recent call last):
  File "test.py", line 4, in <module>
    gi.require_version('Gst', '1.0')
  File "/home/ubuntu/anaconda3/envs/debug/lib/python3.6/site-packages/gi/__init__.py", line 126, in require_version
    raise ValueError('Namespace %s not available' % namespace)
ValueError: Namespace Gst not available

Also I found a bug in your code: instead of obj.start_streaming(), it should be obj.start_streaming.remote().

You have to install GStreamer. You can use following command to install it:
sudo apt-get install gstreamer-1.0

Install gstreamer-1.0 doesn’t fix the issue for me.

Run the following command:

sudo apt-get install python-gi python3-gi \
    	gstreamer1.0-tools \
    	gir1.2-gstreamer-1.0 \
    	gir1.2-gst-rtsp-server-1.0 \
    	gir1.2-gst-plugins-base-1.0 \
    	gstreamer1.0-plugins-good \
    	gstreamer1.0-plugins-ugly \
    	gstreamer1.0-plugins-bad \
    	gstreamer1.0-libav

If you face any issue in import Gst after running above command, please share the issue/error with me.

Still doesn’t work for me.

Traceback (most recent call last):
  File "test.py", line 4, in <module>
    gi.require_version('Gst', '1.0')
AttributeError: module 'gi' has no attribute 'require_version'

Can you try install following modules:
pip install gobject PyGObject

Hi @jjyao ,

Can you please confirm whether you can reproduce the error or not?

Sorry @shyampatel for the late reply.

I was not able to run pip install gobject PyGObject, it failed with

'pkg-config' not found.
  Command ['pkg-config', '--print-errors', '--exists', 'cairo >= 1.15.10']
  ----------------------------------------
  ERROR: Failed building wheel for pycairo
Failed to build PyGObject pycairo
ERROR: Could not build wheels for pycairo, which is required to install pyproject.toml-based projects

But I was able to install it via conda conda install -c conda-forge pygobject.

After that, I’m still facing

Traceback (most recent call last):
  File "test.py", line 4, in <module>
    gi.require_version('Gst', '1.0')
  File "/home/ubuntu/anaconda3/envs/debug/lib/python3.6/site-packages/gi/__init__.py", line 126, in require_version
    raise ValueError('Namespace %s not available' % namespace)
ValueError: Namespace Gst not available

even after I apt-get install everything.

Probably it’s easier for you to help me debug it:

Could you share the entire stacktrace of the error you received? Where did the error happen?

Hi JJyao,
Please find the complete stacktrace below:

Traceback (most recent call last):
  File "/home/kandhavarapu/projects/concor/warehouse/test.py", line 9, in <module>
    class GstServer(GstRtspServer.RTSPServer):
  File "/home/kandhavarapu/.local/lib/python3.10/site-packages/ray/_private/worker.py", line 2896, in remote
    return _make_remote(args[0], {})
  File "/home/kandhavarapu/.local/lib/python3.10/site-packages/ray/_private/worker.py", line 2597, in _make_remote
    return ray.actor._make_actor(function_or_class, options)
  File "/home/kandhavarapu/.local/lib/python3.10/site-packages/ray/actor.py", line 1342, in _make_actor
    _inject_tracing_into_class(Class)
  File "/home/kandhavarapu/.local/lib/python3.10/site-packages/ray/util/tracing/tracing_helper.py", line 540, in _inject_tracing_into_class
    _add_param_to_signature(
  File "/home/kandhavarapu/.local/lib/python3.10/site-packages/ray/util/tracing/tracing_helper.py", line 106, in _add_param_to_signature
    old_sig = inspect.signature(function)
  File "/usr/lib/python3.10/inspect.py", line 3247, in signature
    return Signature.from_callable(obj, follow_wrapped=follow_wrapped,
  File "/usr/lib/python3.10/inspect.py", line 2995, in from_callable
    return _signature_from_callable(obj, sigcls=cls,
  File "/usr/lib/python3.10/inspect.py", line 2558, in _signature_from_callable
    raise ValueError('callable {!r} is not supported by signature'.format(obj))
ValueError: callable gi.FunctionInfo(signal_handler_disconnect) is not supported by signature
Traceback (most recent call last):
  File "temp.py", line 10, in <module>
    class GstServer(GstRtspServer.RTSPServer):
  File "/home/bdonga/Documents/Pipeline/ray_env/lib/python3.8/site-packages/ray/worker.py", line 2276, in remote
    return _make_remote(args[0], {})
  File "/home/bdonga/Documents/Pipeline/ray_env/lib/python3.8/site-packages/ray/worker.py", line 2147, in _make_remote
    return ray.actor.make_actor(function_or_class, options)
  File "/home/bdonga/Documents/Pipeline/ray_env/lib/python3.8/site-packages/ray/actor.py", line 1251, in make_actor
    _inject_tracing_into_class(Class)
  File "/home/bdonga/Documents/Pipeline/ray_env/lib/python3.8/site-packages/ray/util/tracing/tracing_helper.py", line 525, in _inject_tracing_into_class
    add_param_to_signature(
  File "/home/bdonga/Documents/Pipeline/ray_env/lib/python3.8/site-packages/ray/util/tracing/tracing_helper.py", line 102, in add_param_to_signature
    old_sig = inspect.signature(function)
  File "/usr/lib/python3.8/inspect.py", line 3093, in signature
    return Signature.from_callable(obj, follow_wrapped=follow_wrapped)
  File "/usr/lib/python3.8/inspect.py", line 2842, in from_callable
    return _signature_from_callable(obj, sigcls=cls,
  File "/usr/lib/python3.8/inspect.py", line 2405, in _signature_from_callable
    raise ValueError('callable {!r} is not supported by signature'.format(obj))
ValueError: callable gi.FunctionInfo(signal_handler_disconnect) is not supported by signature

Currently Ray requires that each actor method is supported by signature inspection for tracing purpose.

To workaround this, instead of making GstServer a subclass of RTSPServer, could you create a RTSPServer as a class member so GstServer won’t automatically get all the methods from RTSPServer?

I created [Core] Actor methods will be modified for tracing even if tracing is not enabled. · Issue #28293 · ray-project/ray · GitHub to fix the underling issue.

We are receiving pickling issues when we make RTSPServer as a class member. Below is the stack trace:

Traceback (most recent call last):
  File "/home/kandhavarapu/.local/lib/python3.10/site-packages/ray/_private/function_manager.py", line 461, in export_actor_class
    serialized_actor_class = pickle.dumps(Class)
  File "/home/kandhavarapu/.local/lib/python3.10/site-packages/ray/cloudpickle/cloudpickle_fast.py", line 73, in dumps
    cp.dump(obj)
  File "/home/kandhavarapu/.local/lib/python3.10/site-packages/ray/cloudpickle/cloudpickle_fast.py", line 620, in dump
    return Pickler.dump(self, obj)
TypeError: cannot pickle 'GLibProxyModule' object

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/kandhavarapu/projects/concor/warehouse/test.py", line 89, in <module>
    server = GstServer.remote()
  File "/home/kandhavarapu/.local/lib/python3.10/site-packages/ray/actor.py", line 529, in remote
    return self._remote(args=args, kwargs=kwargs, **self._default_options)
  File "/home/kandhavarapu/.local/lib/python3.10/site-packages/ray/util/tracing/tracing_helper.py", line 387, in _invocation_actor_class_remote_span
    return method(self, args, kwargs, *_args, **_kwargs)
  File "/home/kandhavarapu/.local/lib/python3.10/site-packages/ray/actor.py", line 844, in _remote
    worker.function_actor_manager.export_actor_class(
  File "/home/kandhavarapu/.local/lib/python3.10/site-packages/ray/_private/function_manager.py", line 469, in export_actor_class
    raise TypeError(msg) from e
TypeError: Could not serialize the actor class test.GstServer.__init__. Check https://docs.ray.io/en/master/ray-core/objects/serialization.html#troubleshooting for more information.

Oh, that’s a bummer.

Cloud you share your actor class definition? Want to see if we can workaround that.

Please find the actor class definition below:

import gi
import ray

gi.require_version('Gst', '1.0')
gi.require_version('GstRtspServer', '1.0')
from gi.repository import Gst, GstRtspServer, GLib

@ray.remote
class GstServer():
    def __init__(self, **properties):
        Gst.init(None)
        self.server=GstRtspServer.RTSPServer(**properties)
        #super(GstServer, self).__init__(**properties)
        self.loop = GLib.MainLoop()

    def start_streaming(self):
        self.loop.run()

    def stop_streaming(self):
        self.loop.quit()

if __name__ == "__main__":
        obj = GstServer.remote()
        obj.start_streaming()

Hmm, I’m actually not sure why the code needs to pickle GLibProxyModule.

Could you see which line of code triggers that (by commenting it out)?