Skip to content

Commit 76062ae

Browse files
refactor(api): move gethostbyname_cached to utils
1 parent 5956471 commit 76062ae

2 files changed

Lines changed: 8 additions & 7 deletions

File tree

api/desecapi/pdns.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import json
22
import re
3-
import socket
4-
from functools import cache
53
from hashlib import sha1
64

75
import requests
@@ -10,6 +8,7 @@
108

119
from desecapi import metrics
1210
from desecapi.exceptions import PDNSException, RequestEntityTooLarge
11+
from desecapi.utils import gethostbyname_cached
1312

1413
SUPPORTED_RRSET_TYPES = {
1514
# https://doc.powerdns.com/authoritative/appendices/types.html
@@ -84,11 +83,6 @@
8483
}
8584

8685

87-
@cache
88-
def gethostbyname_cached(host):
89-
return socket.gethostbyname(host)
90-
91-
9286
def _pdns_request(
9387
method, *, server, path, data=None, accept="application/json", **kwargs
9488
):

api/desecapi/utils.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import socket
2+
from functools import cache
3+
4+
5+
@cache
6+
def gethostbyname_cached(host):
7+
return socket.gethostbyname(host)

0 commit comments

Comments
 (0)