[6d389a]: / mmaction / utils / misc.py

Download this file

28 lines (20 with data), 618 Bytes

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# Copyright (c) OpenMMLab. All rights reserved.
import ctypes
import random
import string
def get_random_string(length=15):
"""Get random string with letters and digits.
Args:
length (int): Length of random string. Default: 15.
"""
return ''.join(
random.choice(string.ascii_letters + string.digits)
for _ in range(length))
def get_thread_id():
"""Get current thread id."""
# use ctype to find thread id
thread_id = ctypes.CDLL('libc.so.6').syscall(186)
return thread_id
def get_shm_dir():
"""Get shm dir for temporary usage."""
return '/dev/shm'