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

Fix "Address already in use" errors from test_introducer on POSIX #501

Conversation

exarkun
Copy link
Member

@exarkun exarkun commented May 23, 2018

Fixes https://tahoe-lafs.org/trac/tahoe-lafs/ticket/1595 except on Windows (which lacks IReactorSocket support on Python 2). I'll open a new ticket for tracking the Windows fix.

@codecov-io
Copy link

codecov-io commented Jun 8, 2018

Codecov Report

Merging #501 into master will increase coverage by 0.03%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #501      +/-   ##
==========================================
+ Coverage   90.19%   90.23%   +0.03%     
==========================================
  Files         144      144              
  Lines       27466    27466              
  Branches     3939     3939              
==========================================
+ Hits        24773    24783      +10     
+ Misses       1954     1947       -7     
+ Partials      739      736       -3
Impacted Files Coverage Δ
src/allmydata/immutable/upload.py 95.25% <0%> (-0.28%) ⬇️
src/allmydata/stats.py 86.2% <0%> (+0.86%) ⬆️
src/allmydata/immutable/downloader/share.py 95.29% <0%> (+2.46%) ⬆️

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 4c7d13d...1911b35. Read the comment docs.

@exarkun exarkun force-pushed the 1595.address-already-in-use-test_introducer-create_tub branch from e2b9dd7 to 318eea0 Compare June 8, 2018 14:35
Copy link
Contributor

@meejah meejah left a comment

Choose a reason for hiding this comment

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

Looks good to me! A couple inline comments about imports but fine to merge either way.

if portnum is None:
from twisted.internet import reactor
from twisted.internet.interfaces import IReactorSocket
if IReactorSocket.providedBy(reactor):
Copy link
Contributor

Choose a reason for hiding this comment

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

We could probably at least move the interface import to the top? (I'm guessing reactor is imported here "in case something was trying to set a custom reactor"..?)

# actual socket to an address. Once the bind succeeds here, we're
# no longer subject to any future EADDRINUSE problems.
import fcntl
s = socket()
Copy link
Contributor

Choose a reason for hiding this comment

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

import to top? Or is the IReactorSocket part telling us "we're on POSIX so the import can only succeed there"..?

else:
# Get a random port number and fall through. This is necessary on
# Windows where Twisted doesn't offer IReactorSocket. This
# approach is error prone for the reasons described on
Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, my previous comment's question is answered :) -- so maybe a comment that the IReactorSocket check is also telling us if we're POSIX vs Windows?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yea ... for now, anyway. I suppose if someone eventually implements IReactorSocket for some reactor on Windows then this might no longer be the case. And, indeed, I believe fcntl is not available on Windows (https://docs.python.org/2/library/index.html puts it in the "Unix Specific Services" section which I take as a hint in this direction as well).

Copy link
Member Author

Choose a reason for hiding this comment

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

I am reminded of twisted.python.reflect.requireModule, though, which supports an idiom I prefer for maybe-not-available modules. So I'll do that.

@exarkun exarkun merged commit b31b78e into tahoe-lafs:master Jun 8, 2018
@exarkun exarkun deleted the 1595.address-already-in-use-test_introducer-create_tub branch June 8, 2018 20:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants