Coder Social home page Coder Social logo

Tests hanging forever about pytest-sftpserver HOT 10 OPEN

ulope avatar ulope commented on July 23, 2024 1
Tests hanging forever

from pytest-sftpserver.

Comments (10)

ulope avatar ulope commented on July 23, 2024 1

If this is indeed a paramiko issue I assume this issue can be closed?

Note to self: Maybe adding a hint in the readme wouldn't hurt though...

from pytest-sftpserver.

mbyio avatar mbyio commented on July 23, 2024

It looks like you're using the paramiko client? If so, then this is actually a paramiko issue. It opens Python threads in the background to do the actual communication with the server. So you need to actually close the client or it might get stuck.

from pytest-sftpserver.

alfredopalhares avatar alfredopalhares commented on July 23, 2024

I am having ths problem, if its a paramiko issue, is there any links ?
What is the status of this.

from pytest-sftpserver.

christopherdoyle avatar christopherdoyle commented on July 23, 2024

Also encountered this problem, I think sure this is the relevant paramiko issue: paramiko/paramiko#520 (the issue is more widespread than the title). As above, explicitly closing the transport or client fixes it, e.g. from the orignal post adding trans.close() to the end of the test. I think the issue can be closed? I can't see any way of dealing with this in the fixture without monkey patching paramiko.

from pytest-sftpserver.

matteosantama avatar matteosantama commented on July 23, 2024

Similar problem here. Has anyone figured out how to gracefully kill the sftpserver at the end of a test?

from pytest-sftpserver.

alfredopalhares avatar alfredopalhares commented on July 23, 2024

Nope, still nothing on my end. Shame, because this library is not that useful withthis bug.

from pytest-sftpserver.

fiendish avatar fiendish commented on July 23, 2024

Yeah, this happened to me too.

As above, explicitly closing the transport or client fixes it, e.g. from the orignal post adding trans.close() to the end of the test.

Not for me. :\

from pytest-sftpserver.

fiendish avatar fiendish commented on July 23, 2024

@ulope running the server as a thread is probably a mistake. I was able to work around this issue by spawning the server in its own process to eliminate lock contention:

import time
from multiprocessing import Process, Queue
from pytest_sftpserver.sftp.server import SFTPServer


def run_server(q, contents):
    sftpserver = SFTPServer(content_object=contents)
    sftpserver.start()
    q.put((sftpserver.host, sftpserver.port))


def test_some_stuff():
    contents = {}  # my contents structure here

    queue = Queue()
    p = Process(target=run_server, args=(queue, contents), daemon=True)
    p.start()

    for _ in range(10):
        address = queue.get()
        if address:
            break
        time.sleep(0.5)

    assert address

    # <do my testing here>

from pytest-sftpserver.

johannes-cogitaris avatar johannes-cogitaris commented on July 23, 2024

To anyone coming here: This might be an alternative: https://github.com/oz123/pytest-localftpserver

edit: ftp only :-(

from pytest-sftpserver.

tmieulet avatar tmieulet commented on July 23, 2024

see : #30 (comment)
It worked for me:

@pytest.fixture
def sftp_fixture(sftpserver):
    # https://github.com/ulope/pytest-sftpserver/issues/30
    # Tests hanging forever
    sftpserver.daemon_threads = True
    sftpserver.block_on_close = False
    yield sftpserver

from pytest-sftpserver.

Related Issues (17)

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.