On 2016/02/03, at 7:23, Bram Moolenaar <[email protected]> wrote:

> Patch 7.4.1246
> Problem:    The channel functionality isn't tested.
> Solution:   Add a test using a Python test server.

The Python test server doesn't quit and keeps running after the
test (at least on my Mac, OSX 10.8.5, Python2.7).

In test_channel.py, line 76:
                    sys.exit(0)
it seems this terminates only the current thread.

# and it may raise the SystemExit exception. If I run
# $ make check 2>&1 | tee testlog
# then the shell hangs, but this may due to my shell's settings.

Moreover, in test_channel.vim, line 52:
  call system("killall test_channel.py")
this doesn't work either, because the name of the process is
not 'test_channel.py' but 'python'. But of course we don't
want to call 'killall python'.

A possible patch for test_channel.py is attached below.
On my Mac it seems to work.

I don't know how to fix the killall. Without this, the python
process will keep running if something goes wrong and shutdown
fails.

Jun Takimoto


diff --git a/src/testdir/test_channel.py b/src/testdir/test_channel.py
index a706243..b1a8ed8 100755
--- a/src/testdir/test_channel.py
+++ b/src/testdir/test_channel.py
@@ -73,7 +73,8 @@ class 
ThreadedTCPRequestHandler(socketserver.BaseRequestHandler):
                     response = "ok"
                 elif decoded[1] == '!quit!':
                     # we're done
-                    sys.exit(0)
+                    self.server.shutdown()
+                    break
                 else:
                     response = "what?"
 
@@ -95,9 +96,6 @@ if __name__ == "__main__":
     # Start a thread with the server -- that thread will then start one
     # more thread for each request
     server_thread = threading.Thread(target=server.serve_forever)
-
-    # Exit the server thread when the main thread terminates
-    server_thread.daemon = True
     server_thread.start()
 
     # Write the port number in Xportnr, so that the test knows it.
@@ -105,6 +103,7 @@ if __name__ == "__main__":
     f.write("{}".format(port))
     f.close()
 
-    # Block here
     print("Listening on port {}".format(port))
-    server.serve_forever()
+
+    # Main thread terminates, but the server continues running
+    # untill shutdown() is called.



-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Raspunde prin e-mail lui