Giter Site home page Giter Site logo

ervice about rpyc HOT 1 CLOSED

dougbrennan avatar dougbrennan commented on August 23, 2024
ervice

from rpyc.

Comments (1)

comrumino avatar comrumino commented on August 23, 2024

I am unable to reproduce this issue as describe. I tried your examples and recreated a unit test.

import rpyc
from rpyc.utils.server import OneShotServer
import unittest


class MyService(rpyc.Service):

    def exposed_concat(self, remote_str):
        local_str = ' github'
        return remote_str + local_str

class Test_OneShotServer(unittest.TestCase):

    def setUp(self):
        self.server = OneShotServer(MyService, port=18878, auto_register=False)
        self.thd = self.server._start_in_thread()

    def tearDown(self):
        self.server.close()
        self.thd.join()

    def test_server_stops(self):
        conn = rpyc.connect("localhost", port=18878)
        self.assertEqual("hello github", conn.root.concat('hello'))
        conn.close()


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

The output to the above unit test:

Jun 17 16:33:51 DEBUG plumbum.local[MainThread]: Running ['/usr/bin/ssh', '-T', 'localhost', '/bin/sh']
Jun 17 16:33:51 DEBUG plumbum.shell[MainThread]: Running b"true ; echo $? ; echo '--.END1360172845.336028.--' ; echo '--.END1360172845.336028.--' 1>&2"
Jun 17 16:33:51 DEBUG plumbum.shell[MainThread]: 2> b'ssh: connect to host localhost port 22: Connection refused\r\n'
Jun 17 16:33:51 DEBUG plumbum.shell[MainThread]: 1> Nothing returned.
test_server_stops (tests.test_concat.Test_OneShotServer.test_server_stops) ... Jun 17 16:33:51 INFO MY/18878[RpycSpawnThread-builtins.function-93938370855360-139760857434368]: server started on [0.0.0.0]:18878
Jun 17 16:33:51 INFO MY/18878[RpycSpawnThread-builtins.function-93938370855360-139760857434368]: accepted ('127.0.0.1', 33746) with fd 5
Jun 17 16:33:51 INFO MY/18878[RpycSpawnThread-builtins.function-93938370855360-139760857434368]: welcome ('127.0.0.1', 33746)
Jun 17 16:33:51 INFO MY/18878[RpycSpawnThread-builtins.function-93938370855360-139760857434368]: goodbye ('127.0.0.1', 33746)
Jun 17 16:33:51 INFO MY/18878[RpycSpawnThread-builtins.function-93938370855360-139760857434368]: listener closed
Jun 17 16:33:51 INFO MY/18878[RpycSpawnThread-builtins.function-93938370855360-139760857434368]: server has terminated
Jun 17 16:33:51 INFO MY/18878[MainThread]: listener closed
ok

----------------------------------------------------------------------
Ran 1 test in 0.038s

OK

My best guess without being given your output is a connectivity issue: something may be preventing the connection (macOs permissions, Windows AV, etc.) or the server was not running (OneShot will serve a single request before shutting down).

Feel free to reopen with more details such as logs/errors, rpyc version, and operating system.

from rpyc.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.