mirror of
https://github.com/openvswitch/ovs
synced 2025-10-23 14:57:06 +00:00
timeval: Import ctypes Python library within a try statement.
Older versions of Python do not have ctypes as a default installed package. This patch puts the 'import ctypes' statement inside a try statement. This fixes a bug introduced by commit 8396f (timeval: Use monotonic time in OVS Python timeval library). Signed-off-by: Ryan Wilson <wryan@nicira.com> Acked-by: Alex Wang <alexw@nicira.com>
This commit is contained in:
@@ -12,20 +12,20 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
import ctypes
|
|
||||||
import sys
|
|
||||||
import time
|
import time
|
||||||
|
|
||||||
LIBRT = 'librt.so.1'
|
LIBRT = 'librt.so.1'
|
||||||
CLOCK_MONOTONIC = 1
|
CLOCK_MONOTONIC = 1
|
||||||
|
|
||||||
class timespec(ctypes.Structure):
|
try:
|
||||||
|
import ctypes
|
||||||
|
|
||||||
|
class timespec(ctypes.Structure):
|
||||||
_fields_ = [
|
_fields_ = [
|
||||||
('tv_sec', ctypes.c_long),
|
('tv_sec', ctypes.c_long),
|
||||||
('tv_nsec', ctypes.c_long),
|
('tv_nsec', ctypes.c_long),
|
||||||
]
|
]
|
||||||
|
|
||||||
try:
|
|
||||||
librt = ctypes.CDLL(LIBRT)
|
librt = ctypes.CDLL(LIBRT)
|
||||||
clock_gettime = librt.clock_gettime
|
clock_gettime = librt.clock_gettime
|
||||||
clock_gettime.argtypes = [ctypes.c_int, ctypes.POINTER(timespec)]
|
clock_gettime.argtypes = [ctypes.c_int, ctypes.POINTER(timespec)]
|
||||||
|
|||||||
Reference in New Issue
Block a user