Skip to content
This repository has been archived by the owner on Mar 5, 2022. It is now read-only.

2.5 broken on OS X: module 'socket' has no attribute 'TCP_DEFER_ACCEPT' #115

Closed
zmwangx opened this issue Jun 13, 2016 · 9 comments
Closed

Comments

@zmwangx
Copy link
Collaborator

zmwangx commented Jun 13, 2016

OS X 10.11.5, Python 3.5.1, googler 2.5:

> /usr/local/Cellar/googler/2.5/bin/googler --debug --noprompt Homebrew
[DEBUG] Connecting to new host www.google.com
Traceback (most recent call last):
  File "/usr/local/Cellar/googler/2.5/bin/googler", line 579, in new_connection
    self._conn.connect()
  File "/usr/local/Cellar/googler/2.5/bin/googler", line 122, in connect
    sock.setsockopt(socket.SOL_TCP, socket.TCP_DEFER_ACCEPT, 1)
AttributeError: module 'socket' has no attribute 'TCP_DEFER_ACCEPT'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/Cellar/googler/2.5/bin/googler", line 1908, in <module>
    main()
  File "/usr/local/Cellar/googler/2.5/bin/googler", line 1882, in main
    repl = GooglerCmd(opts)
  File "/usr/local/Cellar/googler/2.5/bin/googler", line 1471, in __init__
    self._conn = GoogleConnection(self._google_url.hostname, proxy=proxy)
  File "/usr/local/Cellar/googler/2.5/bin/googler", line 530, in __init__
    self.new_connection(host, port=port, timeout=timeout)
  File "/usr/local/Cellar/googler/2.5/bin/googler", line 582, in new_connection
    raise GoogleConnectionError(msg)
__main__.GoogleConnectionError: Failed to connect to www.google.com: module 'socket' has no attribute 'TCP_DEFER_ACCEPT'.
@zmwangx
Copy link
Collaborator Author

zmwangx commented Jun 13, 2016

http://linux.die.net/man/7/tcp

Apparently TCP_DEFER_ACCEPT is not only not POSIX, but also not available in Linux before 2.4.

@jarun
Copy link
Owner

jarun commented Jun 13, 2016

OK. I'll release 2.5.1 shortly.

@jarun jarun closed this as completed Jun 13, 2016
@jarun jarun reopened this Jun 13, 2016
@jarun
Copy link
Owner

jarun commented Jun 13, 2016

Closed by mistake.

@jarun
Copy link
Owner

jarun commented Jun 13, 2016

I think we can safely assume either none or very small section of our users are on Linux 2.4. So I'll make this change for OS X only.

I am seeing more that 100 ms gain with this option enabled.

Can you please check if 99c1336 works for you?

@zmwangx
Copy link
Collaborator Author

zmwangx commented Jun 13, 2016

TCP_DEFER_ACCEPT isn't the only problem. TCP_QUICKACK is also not available, for instance.

I don't have time to read the code and figure out what each line does, but one should really stick to POSIX. If you want to have separate code for Linux then sure, it's your call; as I said I'll no longer work on new features and this is one, so it won't be my domain.

Here's tcp(4) for you: https://developer.apple.com/legacy/library/documentation/Darwin/Reference/ManPages/man4/tcp.4.html.

@jarun
Copy link
Owner

jarun commented Jun 13, 2016

I don't have time to read the code

I wanted to know if the version is working for you. Not asking you to review the change.

it's your call

Yes, I intend to retain the optimizations for Linux given that both are available in the recent versions. Linux 2.4 was released in Jan 2001.

Commit 77fa658 has all these optimization options enabled only for Linux. Please confirm if this works on your system and I'll make the release.

@zmwangx
Copy link
Collaborator Author

zmwangx commented Jun 13, 2016

I wanted to know if the version is working for you

As said, no. Now it appears to be working.

@zmwangx
Copy link
Collaborator Author

zmwangx commented Jun 13, 2016

Linux 2.4 was released in Jan 2001.

Nowhere do we mention Linux before Jan 2001 is not supported. The usual way to feature test in python is try catch.

@jarun
Copy link
Owner

jarun commented Jun 13, 2016

Nowhere do we mention Linux before Jan 2001 is not supported.

I think we can keep arguing on this but it doesn't make practical sense. If someone comes back with reports on kernel 2.4 we'll provide a patch.

The usual way to feature test in python is try catch.

I didn't want to make extra calls when it's known to fail. I'll re-look at it later.

@zmwangx zmwangx mentioned this issue Jun 13, 2016
@zmwangx zmwangx closed this as completed Jun 13, 2016
@lock lock bot locked and limited conversation to collaborators Nov 15, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants