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

server shutdown mandatory? #97

Open
lindycoder opened this issue Feb 24, 2016 · 3 comments
Open

server shutdown mandatory? #97

lindycoder opened this issue Feb 24, 2016 · 3 comments

Comments

@lindycoder
Copy link

Hi, i've been playing around with your server with this little script:

import redislite
from redis import Redis

server=redislite.Redis(serverconfig={'port': '35000'})

print server.keys()

client = Redis(port=35000)

client.rpush("mykey", "hey")

print server.lpop("mykey")

And i was surprised i couldn't launch the same script twice in a row or else i'd get this error:

Traceback (most recent call last):
  File "redislite_test.py", line 4, in <module>
    server=redislite.Redis(serverconfig={'port': '35000'})
  File ".tox/py27/lib/python2.7/site-packages/redislite/client.py", line 330, in __init__
    self._start_redis()
  File ".tox/py27/lib/python2.7/site-packages/redislite/client.py", line 188, in _start_redis
    'The redis-server process failed to start'
redislite.client.RedisLiteServerStartError: The redis-server process failed to start

After some testing i found that if i add

server.shutdown()

at the end of my script i can run it over and over.

I don't know how much of a bug this is but i couldn't find this in your doc, maybe at least say we need to shutdown manually.

here's some system specs
redislite==3.0.271
OS X El Capitan 10.11.3
Python 2.7.11

Have a nice day

@lindycoder
Copy link
Author

Well it would seem that i overlooked that a process is created with the server that persists after the python program ends, so i couldn't start a new server on the same port because there was already one running.

It feels a little counter intuitive that a server started by a python script would not end with its termination.

I use this for integration testing of an application so my tests starts and ends the server, so maybe it's only my use-case.

@dwighthubbard
Copy link
Contributor

It doesn't shutdown the server process if there active connections to the redis server process that where not created by the current process.

If all activity to the redis server is through redislite Redis or StrictRedis classes then the last process with a connection to the redis server will terminate the redis server. If however a connection is made without going through redislite it's possible for the redis-server process to remain running if that connection is still active when the process that has redislite running terminates.

@lindycoder
Copy link
Author

Okay, that sounds fine.

My use case being exactly connecting without going through redislite so it was confusing for me.

My suggestion was merely to add a little note to the doc, but if you don't feel like it, you can close this issue i won't mind :)

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