[omniORB] Oneway calls not working on local execution

Tomas Staig tomas.staig at gmail.com
Tue Dec 8 15:25:22 UTC 2020


Hi Michael,
    thanks for your reply, indeed my example was not very good because I
used the servant itself in there and not a CORBA object, which of course
would always block and I would have to execute in a separate thread if I
wanted the "oneway" behavior. However the problem happens also working with
a CORBA Object on the same process. So, if I implement the server and
client code in the same script (running in different threads), the call is
still waited to finish for:

import sys
import time
import datetime
from threading import Thread

import AsyncModule
import AsyncModule__POA

from omniORB import CORBA, PortableServer

class AsyncExampleImpl(AsyncModule__POA.AsyncExample):
    def delay(self, sleepSec):
        print(datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S.%f"),
"Start")
        time.sleep(sleepSec)
        print(datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S.%f"),
"Finish")

def client(ior):
    time.sleep(1) #To ensure the orb starts before the client code gets
executed
    orb = CORBA.ORB_init(sys.argv, CORBA.ORB_ID)
    cli_obj = orb.string_to_object(ior)
    cli_obj = cli_obj._narrow(AsyncModule.AsyncExample)
    if cli_obj is None:
        sys.exit(1)

    print(datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S.%f"),
"Before")
    result = cli_obj.delay(2)
    print(datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S.%f"), "After")

orb = CORBA.ORB_init(sys.argv, CORBA.ORB_ID)
poa = orb.resolve_initial_references("RootPOA")

servant = AsyncExampleImpl()
obj = servant._this()

ior = orb.object_to_string(obj)

poaManager = poa._get_the_POAManager()
poaManager.activate()

t = Thread(target=client, args=(ior,))
t.start()
orb.run()
t.join()

2020-12-08 15:15:50.441154 Before
2020-12-08 15:15:50.441386 Start
2020-12-08 15:15:52.442928 Finish
2020-12-08 15:15:52.443160 After

In this later example, I would expect an optimization from
omniORB/omniORBpy avoiding the network call as you suggest, however I would
not expect to lose the one-way behavior of the method call.

Cheers,
Tomas.

On Tue, Dec 8, 2020 at 11:09 AM Michael Teske via omniORB-list <
omniorb-list at omniorb-support.com> wrote:

> Hi Tomas,
>
> if the call goes across the network, one can just send the request and not
> wait for a result, so a oneway doesn't wait.
> But corba calls for local objects result in a normal function call. I
> don't think that there is any exception for
> oneways. To achieve that one would have to route the local request across
> the network, e.g. the loopback interface, and
> I'd say in most cases this would not be wanted. Maybe it's possible to
> convert a local object to an object reference on
> the network which would do exactly that, when called. But if you already
> know your object is local you could start a
> thread for the call yourself, circumventing any CORBA overhead. Can't
> think of any "automatic" solution right now, but
> maybe Duncan has an idea :)
>
> Greetings,
>    Michael
>
> Am 30/11/2020 um 20:04 schrieb Tomas Staig via omniORB-list:
> > Dear all,
> >     we use omniORBpy for a long time now, but just recently we noticed a
> problem with oneway operations when both the
> > client and the servant are on the same process. We have a
> container/component model on top of CORBA, so we don't impose
> > restrictions on the deployment of the CORBA objects, which means this
> situation can happen depending on the developers
> > and the people doing the deployment.
> >
> > I made an isolated test using omniORBpy that exposes the situation:
> > #ifndef _ASYNC_MODULE_IDL_
> > #define _ASYNC_MODULE_IDL_
> >
> > #pragma prefix "acsws"
> >
> > module AsyncModule
> > {
> >      interface AsyncExample {
> >          oneway void delay(in long sleepSec);
> >      };
> > };
> > #endif
> >
> > Then, the implementation would be:
> > import sys
> > import time
> > import datetime
> >
> > import AsyncModule
> > import AsyncModule__POA
> >
> > from omniORB import CORBA, PortableServer
> >
> > class AsyncExampleImpl(AsyncModule__POA.AsyncExample):
> >      def delay(self, sleepSec):
> >          print(datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S.%f"),
> "Start")
> >          time.sleep(sleepSec)
> >          print(datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S.%f"),
> "Finish")
> >
> > orb = CORBA.ORB_init(sys.argv, CORBA.ORB_ID)
> > poa = orb.resolve_initial_references("RootPOA")
> >
> > servant = AsyncExampleImpl()
> > obj = servant._this()
> >
> > poaManager = poa._get_the_POAManager()
> > poaManager.activate()
> >
> > print(datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S.%f"), "Before")
> > result  = obj.delay(2)
> > print(datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S.%f"), "After")
> >
> > The output I receive is the following:
> > 2020-11-30 19:00:38.022027 Before
> > 2020-11-30 19:00:38.022068 Start
> > 2020-11-30 19:00:40.023909 Finish
> > 2020-11-30 19:00:40.024071 After
> >
> > Which shows that the process remained waiting for the oneway operation
> to finish before continuing.
> >
> > When splitting this in two processes (client and server), the output is
> the following:
> > 2020-11-30 19:02:13.797152 Before
> > 2020-11-30 19:02:13.797635 After
> > 2020-11-30 19:02:13.797742 Start
> > 2020-11-30 19:02:15.800049 Finish
> >
> > Which is what I would expect from a oneway operation.
> >
> > Thanks a lot!
> >
> > Best regards,
> > Tomas.
> >
> > _______________________________________________
> > omniORB-list mailing list
> > omniORB-list at omniorb-support.com
> > https://www.omniorb-support.com/mailman/listinfo/omniorb-list
> >
>
>
> _______________________________________________
> omniORB-list mailing list
> omniORB-list at omniorb-support.com
> https://www.omniorb-support.com/mailman/listinfo/omniorb-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.omniorb-support.com/pipermail/omniorb-list/attachments/20201208/551a0408/attachment.html>


More information about the omniORB-list mailing list