Skip to content

Instantly share code, notes, and snippets.

View yong27's full-sized avatar

Hyungyong Kim yong27

View GitHub Profile
@eungju
eungju / threaddump.md
Last active March 6, 2017 10:28
파이썬에서 데드락 해결하기 위해 쓰레드 덤프 얻는 방법.

데드락이 걸렸는데 코드를 봐도 어디인지 모를 때가 있다. 자바는 JVM이 쓰레드 덤프 기능을 제공해서 어떤 쓰레드가 어디서 멈춰 있는지 확인하기 쉬웠는데 파이썬은 쓰레드 덤프를 얻으려면 약간의 코딩이 필요하다.

아래와 같이 모든 쓰레드의 스택 트레이스를 볼 수 있다.

for ident, stack in sys._current_frames().items():
    logger.info(("%d" % ident) + "".join(traceback.format_list(traceback.extract_stack(stack))))

어떤 쓰레드가 멈춰 있는지 안다면 그 쓰레드의 스택 트레이스만 볼 수 있다.

import collections
import sys
def is_valid_fastq(lines):
return (
lines[0].startswith('@') and
lines[2].startswith('+') and
len(lines[1]) == len(lines[3])
)
@thirdj
thirdj / hangul.js
Created April 8, 2013 01:33
한글 초성, 중성, 종성 구분하기
/**
초성 중성 종성 분리 하기
유니코드 한글은 0xAC00 으로부터
초성 19개, 중상21개, 종성28개로 이루어지고
이들을 조합한 11,172개의 문자를 갖는다.
한글코드의 값 = ((초성 * 21) + 중성) * 28 + 종성 + 0xAC00
(0xAC00은 'ㄱ'의 코드값)