Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update imp to use importlib and resolve inspect deprecations #9

Closed
asevans48 opened this issue Oct 29, 2017 · 2 comments
Closed

Update imp to use importlib and resolve inspect deprecations #9

asevans48 opened this issue Oct 29, 2017 · 2 comments

Comments

@asevans48
Copy link

asevans48 commented Oct 29, 2017

When trying to use an actor, imp and initsig warnings appear in Python 3.5+.

Steps to Produce

  1. Create a new project and add code as follows
  2. Create an Actor
  3. Create actor with ActorSystem
  4. Run System

Code

import unittest
import logging
from thespian.actors import Actor, ActorSystem
from reactive.message.base_message import Message


class SourceMessage(Message):
    pass


class TargetMessage(Message):
    pass


class TestSource(Actor):

    def receiveMessage(self, msg, sender):
        if isinstance(msg, TargetMessage):
            msg = "Received Message From {} via {}".format(msg, sender)
            logging.info(msg)
        elif isinstance(msg, SourceMessage):
            if msg.sender is None:
                msg.sender = self
            self.send(msg.target, msg)


class TestTarget(Actor):

    def receiveMessage(self, message, sender):
        if isinstance(message, SourceMessage):
            self.send(sender, 'Received a Message {}'.format(message.payload))
        else:
            logging.info("Received {}".format(message))


class TestActorSystem(unittest.TestCase):

    def test_tell(self):
        asys = ActorSystem("multiprocTCPBase")
        source = asys.createActor(TestSource)
        targ = asys.createActor(TestTarget)
        msg = SourceMessage("Hello From Source", target=targ, sender=source)
        logging.info("Sending {}".format(str(msg)))
        asys.tell(source, msg)
        asys.shutdown()

    def test_ask(self):
        pass

    def test_round_robin_router(self):
        pass

    def test_balancing_router(self):
        pass


if __name__ == "__main__":
    unittest.main()

Expected Results

The actor system should be created and start. The actor should be created. The system should send a message and print the message to the screen.

Cheifly, no warnings are created

Actual Result

The actor system works but warns of deprecated packages

Warnings

.../usr/local/lib/python3.5/dist-packages/thespian/system/sourceLoader.py:66: PendingDeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
  import imp
/usr/local/lib/python3.5/dist-packages/thespian/system/utilis.py:307: DeprecationWarning: inspect.getargspec() is deprecated, use inspect.signature() instead
  initsig = inspect.getargspec(klass.__init__).args
.
@asevans48 asevans48 changed the title Update imp to use importlib Update imp to use importlib and resolve inspect deprecations Oct 29, 2017
@kquick
Copy link
Owner

kquick commented Dec 3, 2017

This is now resolved with recent commits. If you have a chance to verify the behavior in your environment I would appreciate it, @asevans48. This will be part of the next Thespian release.

@kquick
Copy link
Owner

kquick commented Dec 22, 2017

Fixed in release 3.9.0 (https://github.com/kquick/Thespian/releases/tag/thespian-3.9.0). Thanks for the report and the assistance with the fix!

@kquick kquick closed this as completed Dec 22, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants