FeatureRequest: Allow user-defined resolve method for runpy host ip
- Dominant language
- Python
- Stars
- 435
- Forks
- 124
- Avg merge
- 5h 40m
- Merged PRs (30d)
- 14
Description
Currently, the `exechost` is resolved by [`socket.gethostbyaddrsocket`](https://github.com/inducer/relate/blob/master/course/page/code.py#L830) when making the feedback for code questions. When the exechost is not localhost, that require a few seconds for the code to run, if the exechost ip is not resolvable. That lower the speed for response.
```python
import socket
def get_host(i):
for ip in range(i):
try:
socket.gethostbyaddr("192.168.1.%s" % ip)
except socket.error:
pass
%timeit get_host(10)
```
The result is:
```
1min 21s ± 105 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)
```
My idea is to provide user with `settings.RESOLVE_RUNPY_HOST` (a `bool`) to allow user to determine whether to resolve the ip. If not, return the ip. along with `settings.RUNPY_HOST_MAP` (a 'dict'), to map ip/hostnames to strings, for the purpose, for example, to mask the real ip address.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.