Home Help Center

Python servant object cloning policy

spsonispsoni Member Sury P SoniOrganization: Next DigitalProject: Unified Messaging Plattform for Inhouse Products ✭✭
Hi,

I am using Ice for python on freebsd machine.

I am initialising(using constructor) my servant object and associating it with object adapter.

1. My curiosity is that how do Ice clone my servant object to fulfil demand for high load using server thread pool?

2. Can I interfere this cloning process and precisely define, how to clone my objects in python(Are you using copy python module? deep/shallow copy?)? So that I can make sure all my object attribute states are maintained while cloning, if it is not doing is already. I am trying to use class attributes to initialise few of the objects within constructor, rather than creating them outside and passing them as parameter to constructor, so that even if my object gets cloned, I shall retrieve value of the few of the object attributes from class attributes.

Creating objects outside servant objects and passing them to servant class constructor is simple solution, but I need to try class attribute thing to simplify the process.

Please advice.

-Surya

Comments

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

    I may not understand exactly what you're asking, but I can explain what Ice does and does not do.

    First of all, Ice never attempts to clone a servant. If you have configured the thread pool to have multiple threads, it is possible for Ice to dispatch several requests on the same object "concurrently", therefore your servant must be written to protect access to shared data with appropriate locks. I write "concurrently" in quotes because the Python interpreter is single-threaded, so using multiple threads may not always be beneficial.

    If instead you are asking what the Ice run time does when an application attempts to clone a servant, the answer is Nothing. In other words, the generated Python code takes no special action, so you'll get whatever Python offers by default. If you attempt to clone a servant that is actively registered with an object adapter, you will need to take steps to make sure the clone happens atomically.

    If I haven't answered your question, please provide more information.

    Regards,
    Mark
  • spsonispsoni Member Sury P SoniOrganization: Next DigitalProject: Unified Messaging Plattform for Inhouse Products ✭✭
    Hi,
    mes wrote: »
    First of all, Ice never attempts to clone a servant. If you have configured the thread pool to have multiple threads, it is possible for Ice to dispatch several requests on the same object "concurrently", therefore your servant must be written to protect access to shared data with appropriate locks. I write "concurrently" in quotes because the Python interpreter is single-threaded, so using multiple threads may not always be beneficial.

    Your first interpretation of my question is correct. So, your reply clarifies my mis-understanding that thread pool creates a copy/clone of servant object for each active thread in thread pool. But, since, it does not clone any servant object, that makes my life much easier and simple. I can simple worry about locking within the servant object, rather than worrying about the constructor and cloning issues.

    Thank you for your very prompt reply.

    Regards,

    Surya
Sign In or Register to comment.