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

Unclosed Socket #42

Closed
Phill93 opened this issue May 3, 2019 · 3 comments

Comments

Projects
None yet
2 participants
@Phill93
Copy link

commented May 3, 2019

Describe the bug
A socket is opened in line 143 of the getmac.py file. However, this socket is not closed again.

This leads to a "ResourceWarning".

/Users/xxxx/projects/netmap/netmap/network.py:18: ResourceWarning: unclosed <socket.socket fd=3, family=AddressFamily.AF_INET, type=SocketKind.SOCK_DGRAM, proto=0, laddr=('0.0.0.0', 50240)>
  self.mac_address = get_mac_address(ip=str(self.ip_address.ip))
Object allocated at (most recent call last):
  File "/Users/xxxx/projects/netmap/venv/lib/python3.7/site-packages/getmac/getmac.py", lineno 143
    s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)

To Reproduce
Run a unittest that contains a get_mac_address call that requests a mac through a ip.

Expected behavior
No Warning

System info
(please complete the following information):

  • OS name: macOS
  • OS Version: 10.14.4
  • Python version: 3.7.3 x64
  • getmac version: 0.8.0

GhostofGoes added a commit that referenced this issue May 6, 2019

@GhostofGoes

This comment has been minimized.

Copy link
Owner

commented May 6, 2019

Thanks for the report, and apologies for the delay in responding. This is definitely a issue and one I'm surprised has been overlooked until now. I've pushed a potential fix to master, please give it a try. You can install like so: pip install https://github.com/ghostofgoes/getmac/archive/master.tar.gz (that URL works in a requirements.txt/setup.py/etc. as well).

If that fixes it I'll get a point release cut and released as soon as I can.

@GhostofGoes GhostofGoes added the bug label May 9, 2019

@Phill93

This comment has been minimized.

Copy link
Author

commented May 14, 2019

The fix works. Thanks

@GhostofGoes

This comment has been minimized.

Copy link
Owner

commented May 15, 2019

Fix is released on GitHub and uploaded to PyPI as 0.8.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.