# Error while creating actor class

**URL:** <https://discuss.ray.io/t/error-while-creating-actor-class/7323>\
**Category:** Ray Core\
**Created:** [August 25, 2022, 10:04am UTC](https://discuss.ray.io/t/error-while-creating-actor-class/7323 "2022-08-25T10:04:27Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![shyampatel](https://avatars.discourse-cdn.com/v4/letter/s/cab0a1/32.png) [@shyampatel](https://discuss.ray.io/u/shyampatel)\
**Post date:** [August 25, 2022, 10:04am UTC](https://discuss.ray.io/t/error-while-creating-actor-class/7323/1 "2022-08-25T10:04:27Z")

</div>

- High: It blocks me to complete my task.

Getting error while creating instance of actor class.  
Error:

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

```

You can reproduce error with following block of code:

```auto
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.

---

<div class="post-metadata">

**Author:** ![jjyao](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/jjyao/32/1799_2.png) [@jjyao](https://discuss.ray.io/u/jjyao)\
**Post date:** [August 25, 2022, 5:57pm UTC](https://discuss.ray.io/t/error-while-creating-actor-class/7323/2 "2022-08-25T17:57:20Z")

</div>

How can I install `gi`?

---

<div class="post-metadata">

**Author:** ![shyampatel](https://avatars.discourse-cdn.com/v4/letter/s/cab0a1/32.png) [@shyampatel](https://discuss.ray.io/u/shyampatel)\
**Post date:** [August 26, 2022, 4:29am UTC](https://discuss.ray.io/t/error-while-creating-actor-class/7323/3 "2022-08-26T04:29:19Z")

</div>

You can follow this:

> <https://askubuntu.com/questions/80448/what-would-cause-the-gi-module-to-be-missing-from-python>

---

<div class="post-metadata">

**Author:** ![jjyao](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/jjyao/32/1799_2.png) [@jjyao](https://discuss.ray.io/u/jjyao)\
**Post date:** [August 26, 2022, 9:53pm UTC](https://discuss.ray.io/t/error-while-creating-actor-class/7323/4 "2022-08-26T21:53:52Z")

</div>

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

```auto
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()`.

---

<div class="post-metadata">

**Author:** ![shyampatel](https://avatars.discourse-cdn.com/v4/letter/s/cab0a1/32.png) [@shyampatel](https://discuss.ray.io/u/shyampatel)\
**Post date:** [August 27, 2022, 7:04am UTC](https://discuss.ray.io/t/error-while-creating-actor-class/7323/5 "2022-08-27T07:04:39Z")

</div>

> [@jjyao](#):
>
> `ValueError: Namespace Gst not available`

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

---

<div class="post-metadata">

**Author:** ![jjyao](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/jjyao/32/1799_2.png) [@jjyao](https://discuss.ray.io/u/jjyao)\
**Post date:** [August 30, 2022, 3:27am UTC](https://discuss.ray.io/t/error-while-creating-actor-class/7323/6 "2022-08-30T03:27:00Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![shyampatel](https://avatars.discourse-cdn.com/v4/letter/s/cab0a1/32.png) [@shyampatel](https://discuss.ray.io/u/shyampatel)\
**Post date:** [August 30, 2022, 6:12am UTC](https://discuss.ray.io/t/error-while-creating-actor-class/7323/7 "2022-08-30T06:12:56Z")

</div>

Run the following command:

```auto
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.

---

<div class="post-metadata">

**Author:** ![jjyao](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/jjyao/32/1799_2.png) [@jjyao](https://discuss.ray.io/u/jjyao)\
**Post date:** [August 31, 2022, 5:15pm UTC](https://discuss.ray.io/t/error-while-creating-actor-class/7323/8 "2022-08-31T17:15:54Z")

</div>

Still doesn’t work for me.

```auto
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'

```

---

<div class="post-metadata">

**Author:** ![shyampatel](https://avatars.discourse-cdn.com/v4/letter/s/cab0a1/32.png) [@shyampatel](https://discuss.ray.io/u/shyampatel)\
**Post date:** [August 31, 2022, 5:31pm UTC](https://discuss.ray.io/t/error-while-creating-actor-class/7323/9 "2022-08-31T17:31:04Z")

</div>

> [@jjyao](#):
>
> `AttributeError: module 'gi' has no attribute 'require_version'`

Can you try install following modules:  
`pip install gobject PyGObject`

---

<div class="post-metadata">

**Author:** ![shyampatel](https://avatars.discourse-cdn.com/v4/letter/s/cab0a1/32.png) [@shyampatel](https://discuss.ray.io/u/shyampatel)\
**Post date:** [September 3, 2022, 11:55am UTC](https://discuss.ray.io/t/error-while-creating-actor-class/7323/10 "2022-09-03T11:55:33Z")

</div>

Hi @jjyao ,

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

---

<div class="post-metadata">

**Author:** ![jjyao](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/jjyao/32/1799_2.png) [@jjyao](https://discuss.ray.io/u/jjyao)\
**Post date:** [September 5, 2022, 5:58am UTC](https://discuss.ray.io/t/error-while-creating-actor-class/7323/11 "2022-09-05T05:58:29Z")

</div>

Sorry @shyampatel for the late reply.

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

```auto
'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

```auto
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.

---

<div class="post-metadata">

**Author:** ![jjyao](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/jjyao/32/1799_2.png) [@jjyao](https://discuss.ray.io/u/jjyao)\
**Post date:** [September 5, 2022, 6:02am UTC](https://discuss.ray.io/t/error-while-creating-actor-class/7323/12 "2022-09-05T06:02:22Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![krishna](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/krishna/32/3146_2.png) [@krishna](https://discuss.ray.io/u/krishna)\
**Post date:** [September 5, 2022, 10:00am UTC](https://discuss.ray.io/t/error-while-creating-actor-class/7323/13 "2022-09-05T10:00:41Z")

</div>

Hi JJyao,  
Please find the complete stacktrace below:

```auto
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

```

---

<div class="post-metadata">

**Author:** ![shyampatel](https://avatars.discourse-cdn.com/v4/letter/s/cab0a1/32.png) [@shyampatel](https://discuss.ray.io/u/shyampatel)\
**Post date:** [September 5, 2022, 11:19am UTC](https://discuss.ray.io/t/error-while-creating-actor-class/7323/14 "2022-09-05T11:19:28Z")

</div>

> [@jjyao](#):
>
> Could you share the entire stacktrace of the error you received? Where did the error happen?

```auto
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

```

---

<div class="post-metadata">

**Author:** ![jjyao](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/jjyao/32/1799_2.png) [@jjyao](https://discuss.ray.io/u/jjyao)\
**Post date:** [September 6, 2022, 3:38am UTC](https://discuss.ray.io/t/error-while-creating-actor-class/7323/15 "2022-09-06T03:38:07Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![jjyao](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/jjyao/32/1799_2.png) [@jjyao](https://discuss.ray.io/u/jjyao)\
**Post date:** [September 6, 2022, 3:52am UTC](https://discuss.ray.io/t/error-while-creating-actor-class/7323/16 "2022-09-06T03:52:35Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![krishna](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/krishna/32/3146_2.png) [@krishna](https://discuss.ray.io/u/krishna)\
**Post date:** [September 6, 2022, 6:02am UTC](https://discuss.ray.io/t/error-while-creating-actor-class/7323/17 "2022-09-06T06:02:20Z")

</div>

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

```auto
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.

```

---

<div class="post-metadata">

**Author:** ![jjyao](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/jjyao/32/1799_2.png) [@jjyao](https://discuss.ray.io/u/jjyao)\
**Post date:** [September 6, 2022, 10:56pm UTC](https://discuss.ray.io/t/error-while-creating-actor-class/7323/18 "2022-09-06T22:56:51Z")

</div>

Oh, that’s a bummer.

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

---

<div class="post-metadata">

**Author:** ![krishna](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/krishna/32/3146_2.png) [@krishna](https://discuss.ray.io/u/krishna)\
**Post date:** [September 8, 2022, 1:04pm UTC](https://discuss.ray.io/t/error-while-creating-actor-class/7323/19 "2022-09-08T13:04:03Z")

</div>

Please find the actor class definition below:

```auto
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()

```

---

<div class="post-metadata">

**Author:** ![jjyao](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/jjyao/32/1799_2.png) [@jjyao](https://discuss.ray.io/u/jjyao)\
**Post date:** [September 9, 2022, 5:36am UTC](https://discuss.ray.io/t/error-while-creating-actor-class/7323/20 "2022-09-09T05:36:46Z")

</div>

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)?

[Next page](https://discuss.ray.io/t/error-while-creating-actor-class/7323.md?page=2)
