Home Help Center

IcePy and shutdown

alexmalexm Member Eskinder Alex MesfinOrganization: Medtronic, Inc.Project: www.medtronic.com
Hi,
I have a situation where the server started serving multiple instance, shuting it down thru the shutdown mechanism, didn't seem to respond, it takes a long time and eventully I end up killing it, is this normal behaviour or I am missing something.



I run on Sun Solaris 8
Compiled pytton 2.4.2 and Ice* with sun stdio 11.

Comments

  • mesmes CaliforniaAdministrators, ZeroC Staff Mark SpruiellOrganization: ZeroC, Inc.Project: Ice Developer ZeroC Staff
    Hi Alex,

    A server will not complete its shutdown until all pending invocations on its servants have completed. If you don't think this situation is occurring, I suggest attaching a debugger to the server and obtaining a stack trace from each of its threads.

    If you can reproduce this problem consistently with a small example, please post it and we'll take a look at it.

    Take care,
    - Mark
  • alexmalexm Member Eskinder Alex MesfinOrganization: Medtronic, Inc.Project: www.medtronic.com
    IcePy and shutdown

    how do you shutdown an invocation of a servent initiated by a client.
  • mesmes CaliforniaAdministrators, ZeroC Staff Mark SpruiellOrganization: ZeroC, Inc.Project: Ice Developer ZeroC Staff
    alexm wrote:
    how do you shutdown an invocation of a servent initiated by a client.
    Ice does not provide the ability to do that, since it usually would require terminating an active thread and would interfere with aspects of the Ice run time.

    One way to implement such a capability at the application level is to use AMD for all servant invocations, maintain a list of outstanding invocations, and design the servants to periodically check for server termination. For a simple server this might be feasible, but in a complex server it's probably not a viable option.

    Finally, make sure you do not call Communicator.destroy() from within a servant invocation, since this will cause a deadlock. You should only call shutdown() from a servant invocation.

    Take care,
    - Mark
  • alexmalexm Member Eskinder Alex MesfinOrganization: Medtronic, Inc.Project: www.medtronic.com
    How about terminating the client thread instantiated by the servant. It seems the servant is the deamon, am I right? if not how can Ice clean up after the client terminates, and since some pending thread might be the cause of the shutdown delay.
  • matthewmatthew NL, CanadaMember Matthew NewhookOrganization: ZeroC, Inc.Project: Internet Communications Engine ✭✭✭
    Sorry, I don't understand your question. If the method invocation in a server hangs or takes a long time to complete then the shutdown of the server will be delayed until this completes. If this is not the behavior that you want you have to do something special.

    Since Ice is a general piece of software, its not possible for us to do anything different. It is not possible to terminate threads in most operating systems safely (ie: using TerminateThread under Win32 is very bad). Any behaviour that terminates your server unconditionally is highly application specific, and therefore not done by Ice itself.

    If you want to absolutely terminate your server you can call exit. One possible strategy I can think of is that when your server is told to shutdown, you spawn a thread which will call exit in, say, 20 seconds. After communicator->waitForShutdown() returns you terminate this thread. If waitForShutdown() does not return, then your server is hanging and the spawned thread will take care of destroying the server for you.

    Note that if you do this you run the risk of losing data -- which is why Ice does not do this :)
  • eritreaeritrea Member
    matthew wrote:

    If you want to absolutely terminate your server you can call exit. One possible strategy I can think of is that when your server is told to shutdown, you spawn a thread which will call exit in, say, 20 seconds. After communicator->waitForShutdown() returns you terminate this thread. If waitForShutdown() does not return, then your server is hanging and the spawned thread will take care of destroying the server for you.

    Note that if you do this you run the risk of losing data -- which is why Ice does not do this :)

    I will try this.
Sign In or Register to comment.