# Sending objects through messaging between gatways

**URL:** <https://forum.inductiveautomation.com/t/sending-objects-through-messaging-between-gatways/87060>\
**Category:** Ignition\
**Created:** [March 8, 2024, 7:56pm UTC](https://forum.inductiveautomation.com/t/sending-objects-through-messaging-between-gatways/87060 "2024-03-08T19:56:03Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![David.Reed.Schmidt](https://avatars.discourse-cdn.com/v4/letter/d/5f9b8f/32.png) [@David.Reed.Schmidt](https://forum.inductiveautomation.com/u/David.Reed.Schmidt)\
**Post date:** [March 8, 2024, 7:56pm UTC](https://forum.inductiveautomation.com/t/sending-objects-through-messaging-between-gatways/87060/1 "2024-03-08T19:56:03Z")

</div>

Is it possible to send a python class object in a dictionary to a remote gateway.

> system.util.sendMessage(  
> project = 'someProject',  
> messageHandler = 'test',  
> payload = {'AbstractClass': shared.test.AbstractClass()},  
> scope = 'G',  
> remoteServers = remoteServers)

and on the destination gateway message handler

> def handleMessage(payload):  
> payload['AbstractClass'].run()

Is there a better way to distribute code execution among several gateways while maintaining the code in the EAM gateway?

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [March 8, 2024, 8:07pm UTC](https://forum.inductiveautomation.com/t/sending-objects-through-messaging-between-gatways/87060/2 "2024-03-08T20:07:38Z")

</div>

No, python code is not serializable to travel through a network packet, nor is there any way to ensure everything that could get called would be included.

Distribute just the code in projects. Perhaps a dedicated project.

_ **Run** _ the code with indirection, something like this:

> [@Using importlib to run any function on the gateway?](https://forum.inductiveautomation.com/t/using-importlib-to-run-any-function-on-the-gateway/33915/3):
>
> The overall idea is fine, though. Just preload all your possible code in the gateway. Pass function name, positional parameters, and keyword parameters through your sendRequest() call. Say you have script module 'beefyFunctions` set up with all the named functions (which can call other script modules as needed). Create a message handler ‘beefy’ like so: functionName, args, kwargs = [payload[x] for x in ['functionName', 'args', 'kwargs']] return getattr(beefyFunctions, functionName)(\*args, \*…

You message payload and return payload do have to be serialiazable.
