Skip to content

Make kastore_open() work with non-seekable files. - #88

Merged
jeromekelleher merged 8 commits into
tskit-dev:masterfrom
grahamgower:seek-less
Apr 29, 2020
Merged

jeromekelleher merged 8 commits into
tskit-dev:masterfrom
grahamgower:seek-less

Conversation

@grahamgower

Copy link
Copy Markdown
Member

I'd like to read tree sequences from a pipe (e.g. /dev/stdin or a FIFO). There doesn't seem to be any reason this shouldn't be possible. I wasn't sure of the best place to put the tests (C and Python tests wanted, I guess?), so figured I'd submit this as is.

@codecov

codecov Bot commented Mar 29, 2020 •

Copy link
Copy Markdown

Codecov Report

Merging #88 into master will increase coverage by 0.03%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #88      +/-   ##
==========================================
+ Coverage   99.66%   99.70%   +0.03%     
==========================================
  Files           7        7              
  Lines         895     1004     +109     
  Branches       51       66      +15     
==========================================
+ Hits          892     1001     +109     
  Misses          1        1              
  Partials        2        2              
Flag Coverage Δ
#C 99.70% <100.00%> (+0.03%) ⬆️
#python 99.32% <100.00%> (+0.14%) ⬆️
Impacted Files Coverage Δ
c/kastore.c 100.00% <100.00%> (ø)
python/kastore/__init__.py 100.00% <100.00%> (ø)
python/kastore/store.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1cc81b2...15f2d15. Read the comment docs.

@grahamgower

grahamgower commented Mar 29, 2020 •

Copy link
Copy Markdown
Member Author

Upon further investigation, this looks like it will be an API change in order to signal EOF back to the user. I managed to get the following test code working. The python engine would need more effort.

$ cat kas_stream.py
#!/usr/bin/env python3

import sys
import kastore
import time

if len(sys.argv) != 2 or sys.argv[1] not in ("read", "cread", "write", "cwrite"):
    print(f"usage: {sys.argv[0]} [read | cread | write | cwrite]", file=sys.stderr)
    exit(1)

engine = kastore.PY_ENGINE
if sys.argv[1] in ("cread", "cwrite"):
    engine = kastore.C_ENGINE
    sys.argv[1] = sys.argv[1][1:]

if sys.argv[1] == "read":
    i = 0
    while True:
        i += 1
        try:
            data = kastore.load("/dev/stdin", read_all=True, engine=engine)
        except EOFError:
            break
        print(f"data[{i}] = {data}", file=sys.stderr)
elif sys.argv[1] == "write":
    data = { "t": [time.clock_gettime_ns(time.CLOCK_BOOTTIME)],
             "foo": [0x66, 0x6f, 0x6f] }
    kastore.dump(data, "/dev/stdout", engine=engine)
$ ./kas_stream.py cwrite | ./kas_stream.py cread
data[1] = {'foo': array([102, 111, 111]), 't': array([1750695652051672])}
$ for _ in `seq 5`; do ./kas_stream.py cwrite ; done | ./kas_stream.py cread
data[1] = {'foo': array([102, 111, 111]), 't': array([1750700764258480])}
data[2] = {'foo': array([102, 111, 111]), 't': array([1750700850537828])}
data[3] = {'foo': array([102, 111, 111]), 't': array([1750700936927463])}
data[4] = {'foo': array([102, 111, 111]), 't': array([1750701022869487])}
data[5] = {'foo': array([102, 111, 111]), 't': array([1750701116848339])}

@jeromekelleher

Copy link
Copy Markdown
Member

Thanks for this @grahamgower, it's very helpful. I agree we should support reading tskit files from a stdin, so let's figure out how to make this work.

One thing to bear in mind though, is that currently tskit keeps the kastore open for the lifetime of a table collection object, as it uses the memory from the kastore for columns. This is a relic of an attempt to make tree sequence loading copy-free by using mmap. However, it turns out that mmap is inherently unsafe (if someone truncates the file while it's mmap'd you get a bus error) and that actually memcopying a few gigs of data (at most) is pretty quick, so there's no point in worrying about it. So we want to move away from this in tskit, and we'll then be compatible with reading from stdin.

Probably another change we'll want to make is to pass a file descriptor through to kastore so that we can read from arbitrary pipes rather than having some protocol for interpreting strings. I guess what we want is another open function for this.

How about we line up a quick call to chat through the details @grahamgower?

cc @benjeffery --- this is relevant to stuff we were talking about on Friday.

@grahamgower

Copy link
Copy Markdown
Member Author

Probably another change we'll want to make is to pass a file descriptor through to kastore so that we can read from arbitrary pipes rather than having some protocol for interpreting strings. I guess what we want is another open function for this.

Yep, this was probably going to be my next move. There's some weirdness with the test code I posted if it's changed to kastore.dump(..., "/dev/stdout") multiple times in one python process---the reader doesn't always see input after the first kastore.dump().

Happy to have a chat this afternoon if you're free. This is just for some hobby code btw, so I might not follow up particularly strongly if it looks too involved.

@jeromekelleher

Copy link
Copy Markdown
Member

Happy to have a chat this afternoon if you're free. This is just for some hobby code btw, so I might not follow up particularly strongly if it looks too involved.

Sure, say 2pm BST? No pressure to take things any further - even if we just get this specced out in a some issues we've done good work here.

@grahamgower

Copy link
Copy Markdown
Member Author

2pm BST works for me.

@jeromekelleher jeromekelleher left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great, thanks @grahamgower. As we discussed, it might be simplest to refactor the Python API now to get rid of mmap (#58) so we can don't seek any more. We can add the stuff for supporting arbitrary files afterwards as a follow on.

Comment thread c/kastore.h Resolved
Comment thread c/kastore.h Resolved
@grahamgower

Copy link
Copy Markdown
Member Author

I think that just leaves fixing certain tests to expect EOFError instead of kastore.FileFormatError. All combinations of read/write/cread/cwrite, etc. work with the below test script.

$ cat kas_stream.py
#!/usr/bin/env python3

import sys
import kastore

if len(sys.argv) != 2 or sys.argv[1] not in ("read", "cread", "write", "cwrite"):
    print(f"usage: {sys.argv[0]} [read | cread | write | cwrite]", file=sys.stderr)
    exit(1)

engine = kastore.PY_ENGINE
if sys.argv[1] in ("cread", "cwrite"):
    engine = kastore.C_ENGINE
    sys.argv[1] = sys.argv[1][1:]

if sys.argv[1] == "read":
    i = 0
    while True:
        try:
            data = kastore.load("/dev/stdin", read_all=True, engine=engine)
        except EOFError:
            break
        print(f"data[{i}] = {list(data.items())}", file=sys.stderr)
        i += 1
elif sys.argv[1] == "write":
    for i in range(5):
        kastore.dump({ "i": [i] }, "/dev/stdout", engine=engine)

@grahamgower

Copy link
Copy Markdown
Member Author

Needs a few more tests for the exception paths in store.py. It's not so obvious to me how to trigger these cases. Or maybe some of these code paths can't happen because of earlier exceptions?

$ nosetests -xv --with-coverage --cover-package=kastore tests
...
$ coverage report -m
Name                    Stmts   Miss  Cover   Missing
-----------------------------------------------------
kastore/__init__.py        41      0   100%
kastore/__main__.py         5      1    80%   9
kastore/_version.py         1      0   100%
kastore/cli.py             75      0   100%
kastore/exceptions.py       9      0   100%
kastore/store.py          269      6    98%   268, 315, 339, 357, 359, 401
-----------------------------------------------------
TOTAL                     400      7    98%

@jeromekelleher jeromekelleher left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, thanks @grahamgower! I'm not convinced the semantics of EOF'ing any time we get a truncated stream is what we want to do, but maybe I'm wrong.

Comment thread c/kastore.c Resolved
Comment thread python/kastore/store.py Resolved
Comment thread python/kastore/store.py Resolved
Comment thread python/kastore/store.py Resolved
Comment thread python/kastore/store.py Resolved
Comment thread python/kastore/store.py Resolved
@grahamgower

Copy link
Copy Markdown
Member Author

Still needs more test coverage, but most of the changes are done. It turns out that supporting streaming without using kastore_openf() and/or kastore.load(file_like_object)/kastore.dump(..., file_like_object) has lots of edge-case problems which don't exist when the file is just open for the lifetime of the stream. So I might wind back some of the changes I made earlier that attempted to get that working. And I now agree that EOF should only be raised when 0 bytes are read at the start of a store, so I'll rewind those changes too.

@jeromekelleher

Copy link
Copy Markdown
Member

Looks good, thanks @grahamgower. My queue has built up a bit over the weekend, so I'll need to loop back on this one and think it through properly. Should get to it in a couple of days.

@jeromekelleher jeromekelleher left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great, thanks @grahamgower! On reflection I think it's simpler if we do actually implement access to this in the C Engine in the Python API. Probably the simplest way to do this is to add another argument, fd to the kastore_dump() and kastore_load() functions in the low level API. This is mutually exclusive with filename. If fd is specified, we create a FILE* from it using fdopen.

Or, probably a simpler thing to do would be to create a new pair of functions, dumpf and loadf which just take an fd. This can then be linked up with the high-level API easily enough.

Or, maybe we could use the Python C API to take in a python file obj, and get an FILE* from it? I'm not sure what the best approach is. But, anyway, I think we do need to do it, or we'll never have full confidence in the C API working from pipes, etc.

Comment thread c/kastore.c Resolved
Comment thread c/kastore.c Resolved
Comment thread c/kastore.c Resolved
Comment thread c/kastore.c Resolved
Comment thread c/kastore.c Resolved
Comment thread python/kastore/__init__.py Resolved
Comment thread python/kastore/__init__.py Resolved
Comment thread python/kastore/store.py Resolved
Comment thread python/kastore/store.py Resolved
Comment thread python/kastore/store.py Resolved
@grahamgower

Copy link
Copy Markdown
Member Author

This is great, thanks @grahamgower! On reflection I think it's simpler if we do actually implement access to this in the C Engine in the Python API. Probably the simplest way to do this is to add another argument, fd to the kastore_dump() and kastore_load() functions in the low level API. This is mutually exclusive with filename. If fd is specified, we create a FILE* from it using fdopen.

Or, probably a simpler thing to do would be to create a new pair of functions, dumpf and loadf which just take an fd. This can then be linked up with the high-level API easily enough.

Or, maybe we could use the Python C API to take in a python file obj, and get an FILE* from it? I'm not sure what the best approach is. But, anyway, I think we do need to do it, or we'll never have full confidence in the C API working from pipes, etc.

I think the first of these suggestions is the path of least resistance. I'll have a think, play with some code, and get back to you.

* Remove call to fseek when the KAS_READ_ALL flag is set.
* Signal EOF, so the user can detect when a stream has been closed.
Changes are analogous to those made for the c engine, in particular:
 * Don't use tell(), and don't seek() with read_all=True.
 * Remove mmap (restructuring the Store class was necessary anyway).
@grahamgower

Copy link
Copy Markdown
Member Author

Back around the merry-go round. :)

The C tests are still missing. And tests/test_fileobj.py:StreamingMixin() is positively horrible (and has a race, which is the cause of the CI failure). It turns out to be quite tricky to have an exception in a multiprocessing.Process returned to the parent while retaining a record of the stack frame. I might instead try using concurrent.futures for the streaming tests (Future objects at least have an exception() method which might be good enough)

@grahamgower

Copy link
Copy Markdown
Member Author

This is great, thanks @grahamgower! On reflection I think it's simpler if we do actually implement access to this in the C Engine in the Python API. Probably the simplest way to do this is to add another argument, fd to the kastore_dump() and kastore_load() functions in the low level API. This is mutually exclusive with filename. If fd is specified, we create a FILE* from it using fdopen.

Or, probably a simpler thing to do would be to create a new pair of functions, dumpf and loadf which just take an fd. This can then be linked up with the high-level API easily enough.

Or, maybe we could use the Python C API to take in a python file obj, and get an FILE* from it? I'm not sure what the best approach is. But, anyway, I think we do need to do it, or we'll never have full confidence in the C API working from pipes, etc.

I ended up doing something more like your third suggestion, but creating the FILE* using fdopen. Python 3 doesn't use FILE* internally (unlike python 2), which means the only option is to use the python object's fileno().

@jeromekelleher jeromekelleher left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is AWESOME @grahamgower, really excellent! I can have a go at tweaking the streaming tests if you like? I'd also like to write some low-level tests to make sure we're getting all the corner cases in the Python-C interface (stuff like passing a bad fd and making sure we clean up properly). But we're basically done, I think.

Comment thread c/kastore.c Resolved
Comment thread python/_kastoremodule.c Resolved
Comment thread python/kastore/__init__.py Resolved
@grahamgower

Copy link
Copy Markdown
Member Author

This is AWESOME @grahamgower, really excellent! I can have a go at tweaking the streaming tests if you like? I'd also like to write some low-level tests to make sure we're getting all the corner cases in the Python-C interface (stuff like passing a bad fd and making sure we clean up properly). But we're basically done, I think.

Yes, please do. I likely wont get back to this for a couple of weeks, so I'd be happy if you polished and/or whacked any bits you're not entirely convinced about.

@jeromekelleher

Copy link
Copy Markdown
Member

OK, great. I'll make a pass at this and get back to you for final approval before merging.

@jeromekelleher
jeromekelleher force-pushed the seek-less branch 2 times, most recently from 93edab1 to fc0b85c Compare April 27, 2020 18:06
@jeromekelleher

Copy link
Copy Markdown
Member

Grrr. I still can't get a working test case for the socket case. Everything works fine (well almost, there's still some bugs in the Py engine) when I run this program:

import socketserver
import socket
import sys
import kastore
import numpy as np


class MyTCPHandler(socketserver.BaseRequestHandler):
    def handle(self):
        print("{} connected:".format(self.client_address[0]))
        for data in self.server.data_list:
            # encoded = kastore.dumps(data)
            # print("Writing", len(encoded), "bytes")
            # self.request.sendall(encoded)
            kastore.dump(data, self.request.fileno(), engine=kastore.C_ENGINE)


if __name__ == "__main__":
    HOST, PORT = "localhost", 9990

    data_list = [{"a": np.arange(j * 1000, dtype=np.int8)} for j in range(200)]
    if sys.argv[1] == "1":

        # Create the server, binding to localhost on port 9999
        server = socketserver.TCPServer((HOST, PORT), MyTCPHandler)
        server.data_list = data_list

        # Activate the server; this will keep running until you
        # interrupt the program with Ctrl-C
        server.serve_forever()
    else:

        # Create a socket (SOCK_STREAM means a TCP socket)
        sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

        try:
            # Connect to server and send data
            sock.connect((HOST, PORT))
            received_list = []
            while True:
                try:
                    d = kastore.load(sock.fileno(), engine=kastore.PY_ENGINE, read_all=True)
                except EOFError:
                    break
                received_list.append(d)
            print("recieved", len(received_list))
            for a, b in zip(received_list, data_list):
                # print(a, b)
                assert len(a) == len(b)

        finally:
            try:
                sock.close()
            except OSError as ose:
                print("Error on sock close", ose)

But when I try to run the Socket test cases (which basically to the same thing) it's deadlocking. It seems to be blocking on creating the server handler threads, but I've no idea why. It must be something to do with the fact we're using fds rather than actual sockets.

This is a very good test though, so I'd really like to get it working. Any chance you could have a go @grahamgower?

@grahamgower

Copy link
Copy Markdown
Member Author

I really don't know what's going on here @jeromekelleher, but the use of threading makes me nervous. I added some debug print statements, and for some reason this made a threading exception pop up that I don't see without the print statements. A likely cause of the deadlock, as the server thread has died. Maybe you have some insight?

$ python3 -u -m nose -sv tests/test_fileobj.py:TestSocketCEngine
test_single (tests.test_fileobj.TestSocketCEngine) ... TestServer: server_bind
TestServer: server_activate
Running server thread 140442562029312
TestServer: serve_forever
TestServer: fileno
Exception in thread Thread-1:
server_thread <Thread(Thread-1, started 140442562029312)>
simple test with socket
Traceback (most recent call last):
  File "/usr/lib/python3.8/threading.py", line 932, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.8/threading.py", line 870, in run
    reading from sockself._target(*self._args, **self._kwargs)
  File "/home/grg/src/kastore/python/tests/test_fileobj.py", line 359, in f
4
diff --git a/python/tests/test_fileobj.py b/python/tests/test_fileobj.py
index 5f2c5a2..73049aa 100644
--- a/python/tests/test_fileobj.py
+++ b/python/tests/test_fileobj.py
@@ -276,9 +276,70 @@ class StreamingMixin(DictVerifyMixin):
 
 class TestServer(socketserver.ThreadingTCPServer):
     allow_reuse_address = True
+    block_on_close = False
+    timeout = 3
+
+    def fileno(self, *args, **kwargs):
+        print("TestServer: fileno")
+        super().fileno(*args, **kwargs)
+
+    def handle_request(self, *args, **kwargs):
+        print("TestServer: handle_request")
+        super().handle_request(*args, **kwargs)
+
+    def serve_forever(self, *args, **kwargs):
+        print("TestServer: serve_forever")
+        super().serve_forever(*args, **kwargs)
+
+    def service_actions(self, *args, **kwargs):
+        print("TestServer: service_actions")
+        super().service_actions(*args, **kwargs)
+
+    def shutdown(self, *args, **kwargs):
+        print("TestServer: shutdown")
+        super().shutdown(*args, **kwargs)
+
+    def server_close(self, *args, **kwargs):
+        print("TestServer: server_close")
+        super().server_close(*args, **kwargs)
+
+    def finish_request(self, *args, **kwargs):
+        print("TestServer: finish_request")
+        super().finish_request(*args, **kwargs)
+
+    def get_request(self, *args, **kwargs):
+        print("TestServer: get_request")
+        super().get_request(*args, **kwargs)
+
+    def handle_error(self, *args, **kwargs):
+        print("TestServer: handle_error")
+        super().handle_error(*args, **kwargs)
+
+    def handle_timeout(self, *args, **kwargs):
+        print("TestServer: handle_timeout")
+        super().handle_timeout(*args, **kwargs)
+
+    def process_request(self, *args, **kwargs):
+        print("TestServer: process_request")
+        super().process_request(*args, **kwargs)
+
+    def server_activate(self, *args, **kwargs):
+        print("TestServer: server_activate")
+        super().server_activate(*args, **kwargs)
+
+    def server_bind(self, *args, **kwargs):
+        print("TestServer: server_bind")
+        super().server_bind(*args, **kwargs)
+
+    def verify_request(self, *args, **kwargs):
+        print("TestServer: verify_request")
+        super().verify_request(*args, **kwargs)
+
 
 
 class ServerWriteRequestHandler(socketserver.BaseRequestHandler):
+    def setup(self):
+        print("SERVER SETUP")
 
     def handle(self):
         print("HANDLER STARTED", self.server.socket, threading.get_ident())
@@ -360,11 +421,11 @@ class TestStreamingPyEngine(StreamingMixin, unittest.TestCase):
     engine = kas.PY_ENGINE
 
 
[email protected]("socket deadlock")
+#@unittest.skip("socket deadlock")
 class TestSocketPyEngine(SocketMixin, unittest.TestCase):
     engine = kas.PY_ENGINE
 
 
[email protected]("socket deadlock")
+#@unittest.skip("socket deadlock")
 class TestSocketCEngine(SocketMixin, unittest.TestCase):
     engine = kas.C_ENGINE

@grahamgower

Copy link
Copy Markdown
Member Author

Ah! It's more informative without unbuffered output enabled (no -u python flag below)

$ python3 -m nose -sv tests/test_fileobj.py:TestSocketCEngine
test_single (tests.test_fileobj.TestSocketCEngine) ... TestServer: server_bind
TestServer: server_activate
Running server thread 140215741265664
TestServer: serve_forever
TestServer: fileno
Exception in thread Thread-1:
Traceback (most recent call last):
  File "/usr/lib/python3.8/threading.py", line 932, in _bootstrap_inner
server_thread <Thread(Thread-1, started 140215741265664)>
    self.run()
  File "/usr/lib/python3.8/threading.py", line 870, in run
    self._target(*self._args, **self._kwargs)
simple test with socket
  File "/home/grg/src/kastore/python/tests/test_fileobj.py", line 359, in f
    self.server.serve_forever()
  File "/home/grg/src/kastore/python/tests/test_fileobj.py", line 292, in serve_forever
    super().serve_forever(*args, **kwargs)
  File "/usr/lib/python3.8/socketserver.py", line 229, in serve_forever
    selector.register(self, selectors.EVENT_READ)
  File "/usr/lib/python3.8/selectors.py", line 352, in register
    key = super().register(fileobj, events, data)
  File "/usr/lib/python3.8/selectors.py", line 238, in register
    key = SelectorKey(fileobj, self._fileobj_lookup(fileobj), events, data)
  File "/usr/lib/python3.8/selectors.py", line 225, in _fileobj_lookup
    return _fileobj_to_fd(fileobj)
  File "/usr/lib/python3.8/selectors.py", line 39, in _fileobj_to_fd
    raise ValueError("Invalid file object: "
reading from sock 4
ValueError: Invalid file object: <tests.test_fileobj.TestServer object at 0x7f86857f83a0>

@grahamgower

Copy link
Copy Markdown
Member Author

Ok, I'm an idiot. I overwrote the fileno() method but didn't return a value. :)

@jeromekelleher

Copy link
Copy Markdown
Member

Huh, playing around with this a bit more, looks like it's blocking on the FD at the client side. If we use plain recv's at the client it works (even if the server is writing to the fd)...

@grahamgower

Copy link
Copy Markdown
Member Author

Yep, I've just now discovered the same thing. Are you seeing the print() statements from the server thread? I'm not. I changed it to use a multiprocessing.Process instead of a thread, and now I see the server print()s.

@jeromekelleher

jeromekelleher commented Apr 29, 2020 •

Copy link
Copy Markdown
Member

Aha! If we use the C_ENGINE as the server and the PY_ENGINE as the client it all works. So, looks like we're uncovering actual problems here.

Spoke too soon, it deadlocks all right just later on when we move more stuff around. Probably there's some issue with threading, you're right.

@grahamgower

Copy link
Copy Markdown
Member Author

I reckon it's a buffering issue with the underlying socket object.

@jeromekelleher

Copy link
Copy Markdown
Member

I reckon it's a buffering issue with the underlying socket object.

I'm trying out a different architecture using a Process for the server. Let's see.

@grahamgower

Copy link
Copy Markdown
Member Author

Helps if we write to the request file descriptor.

diff --git a/python/tests/test_fileobj.py b/python/tests/test_fileobj.py
index 5f2c5a2..f67ddb6 100644
--- a/python/tests/test_fileobj.py
+++ b/python/tests/test_fileobj.py
@@ -283,8 +283,8 @@ class ServerWriteRequestHandler(socketserver.BaseRequestHandler):
     def handle(self):
         print("HANDLER STARTED", self.server.socket, threading.get_ident())
         for data in self.server.data_list:
-            print("Writing to", self.server.fileno())
-            kas.dump(data, self.server.fileno(), engine=self.server.engine)
+            print("Writing to", self.request.fileno())
+            kas.dump(data, self.request.fileno(), engine=self.server.engine)
             print("written")

@jeromekelleher

Copy link
Copy Markdown
Member

Nice, great stuff @grahamgower. I figured out a different way to make it work, but lets do both. I'll update here in a bit, and ask for a final review from you then.

@grahamgower

Copy link
Copy Markdown
Member Author

Nice, great stuff @grahamgower. I figured out a different way to make it work, but lets do both. I'll update here in a bit, and ask for a final review from you then.

Ok, sounds good. I'll stop pushing to the branch.

@jeromekelleher

Copy link
Copy Markdown
Member

Your one is still deadlocking for me occasionally @grahamgower - mind if I rewind the branch back to where I was and force-push so you can see what I've done?

@grahamgower

Copy link
Copy Markdown
Member Author

Sure, go ahead.

I ran my version in a loop for a while and couldn't provoke any problems. Maybe there's a version descrepancy?

@jeromekelleher

Copy link
Copy Markdown
Member

OK, done. Can you have a look through please @grahamgower? What do you think of the EchoServer stucture - seems pretty robust to me now as communication between the processes is kept to a minimum. I'm happy to bring in your version of the server in too, if you like - it's probably testing slightly different weird timing stuff, which does shake out bugs. I'm fairly sure it was deadlocking for me, but I can try it again if we want to put it in.

Assuming we're happy with this now I think we can merge. If you're happy I/you can rebase and squash my commits into one. Ready to merge then I think.

Comment thread python/tests/test_fileobj.py Resolved
@grahamgower

Copy link
Copy Markdown
Member Author

Looks good @jeromekelleher, I'm just slightly worried about the call to self.server.shutdown().

@grahamgower

Copy link
Copy Markdown
Member Author

Sorry, I have to run off and do other things now @jeromekelleher. But it looks great, so please squish and merge!

@jeromekelleher

Copy link
Copy Markdown
Member

will do @grahamgower. Thanks for all this work, this is a huge power-up for tskit-dev!!!

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

Successfully merging this pull request may close these issues.

2 participants