회원 로그인
정보기억 정보기억에 체크할 경우 다음접속시 아이디와 패스워드를 입력하지 않으셔도 됩니다.
그러나, 개인PC가 아닐 경우 타인이 로그인할 수 있습니다.
PC를 여러사람이 사용하는 공공장소에서는 체크하지 마세요.
소셜네트워크 서비스를 통해서 로그인하시면 별도의 로그인 절차없이 회원서비스를 이용하실 수 있습니다.


최근 게시물

1.노션에서 작성 중

1.노션에서 작성 중

개편하기 전까지 노션에서 작성 중

2024.04.04//read more

2.ChatGPT

2.ChatGPT

OpenAI로 대규모 언어 모델대화형...

2023.03.16//read more

3.노코딩 게임 엔진 - 빌..

3.노코딩 게임 엔진 - 빌..

빌드 지원안드로이드iOS윈도우즈특이사...

2023.03.14//read more

4.(완료) 미접속 회원 정..

4.(완료) 미접속 회원 정..

[완료] 36명의 회원을 정리하였습니...

2023.02.16//read more

5.매뉴얼 플러스 - 전자제..



안정적인 DNS 서비스 DNSEver
DNS Powered by DNSEver.com


[스크랩] Maya help에 있는 Python 참조문 번역 - Python and threading

artsone | 2008.01.15 17:02 | 조회 4691

이 부분은 프로그래밍적 개념이 어려워서 도저히 이해가 않가는 부분입니다. 그래서 역주가 비약한 점 미리 말해드립니다.

thread란?
컴퓨터 프로그램 수행 시 프로세스 내부에 존재하는 수행 경로, 즉 일련의 실행 코드. 프로세스는 단순한 껍데기일 뿐, 실제 작업은 스레드가 담당한다. 프로세스 생성 시 하나의 스레드 가 생성되어 대부분의 작업을 처리하고 주 스레드가 종료되면 프로세스도 종료된다. 하나의 운영체계 에서 여러 개의 프로세스가 동시에 실행되는 환경이 멀티테스킹 이고, 하나의 프로세스 내에서 다수의 스레드가 동시에 수행되는 것이 멀티스레딩이다.



Python and threading

The Python language comes with built-in threading support. This functionality is available within Maya, but there are some significant constraints that Python developers need to be aware of.
Python언어는 내장 thread지원과 함께 만들어졌다. 이 기능은 Maya에서도 허용되지만 약간의 Python 개발자가 알아두어야할 제약이 있다.

Maya API and Maya Command architectures are not thread-safe. Maya commands throw an exception if they are called outside the main thread, and use of the OpenMaya API from threads other than the main one has unforeseen side effects.
Maya API와 명령어 시스템 구조의 thread는 안전하지 못하다. Thread가 main thread 밖으로 호출되면 maya명령어는 예외를 발생시키고, main thred로부터 openMaya API의 사용은 생각지 않은 부작용을 갖는다.

Despite restrictions, there are many potential uses for threading in Python within the context of Maya; for example, spawning a thread to watch a socket for input. To make the use of Python threads more practical, we have provided a way for other threads to execute code in the main thread and wait upon the result.

The maya.utils.executeInMainThreadWithResult() function takes either a string containing Python code or a Python callable object such as a function. In the latter case, executeInMainThreadWithResult() also accepts both regular and keyword arguments that are passed on to the callable object when it is run.

The script or callable object is executed in the main thread during the next idle event. The thread calling executeInMainThreadWithResult() blocks until the main thread becomes idle and runs the code. Once the main thread is done executing the code, executeInMainThreadWithResult() returns the result. If executeInMainThreadWithResult() is called from the main thread, then it simply runs the code immediately and returns the result.

Because idle events are being used to implement executeInMainThreadWithResult(), it is not available in batch mode.
왜냐하면 입력·출력을 위한 대기는 executeInMainThreadWithResult()를 이행하는데 이용되고 있기 때문이다. 입력·출력을 위한 대기는 batch mode에서는 이용할 수 없다.

import maya.utils
import maya.cmds
def doSphere( radius ):
maya.cmds.sphere( radius=radius )
maya.utils.executeInMainThreadWithResult( doSphere, 5.0 )


maya.utils

The maya.utils package is where utility routines that are not specific to either the API or Commands are stored. This module will likely expand in future versions.
package는 API나 명령어에 명확하지 않은 utility routines가 저장되는 장소이다. 이 모듈은 다음 버젼에 확장될 것이다.

Currently, the maya.utils package contains three routines relevant to threading (see the previous section for details on executeInMainThreadWithResult).
지금은, maya.utils package가 threading에 관련된 3개의 routine만이 포함하고 있다. (executeInMainThreadWithResult의 좀더 자세한 설명을 위해 앞의 section을 보라)

There are two other routines in maya.utils:
maya.utils에 있는 다른 두개의 routine이다:

* maya.utils.processIdleEvents().

It is mostly useful for testing: it forces the processing of any queued up idle events.
이 routine은 주로 test하는데 유용하다: 그 routine은 밀려있는 입력·출력을 위한 대기의 처리를 강행한다.

* maya.utils.executeDeferred().

(Similar to maya.utils.executeInMainThreadWithResult() except that it does not wait for the return value.) It delays the execution of the given script or function until Maya is idle. This function runs code using the idle event loop. This means that the main thread must become idle before this Python code is executed.
(되돌아오는 값을 기다리지 않는다는 것을 제외하고는 maya.utils.executeInMainThreadWithResult()와 비슷하다) 그 routine은 주어진 스크립트의 실행을 maya가 멈출 때까지 지연시킨다. 이 routine은 입출력을 위한 대기 loop을 써서 코드를 실행 시킨다. 이것은 main thread가 Python 코드 실행전에 멈춰져야 된다는 것을 뜻한다.

There are two different ways to call this function. The first is to supply a single string argument which contains the Python code to execute. In that case the code is interpreted. The second way to call this routine is to pass it a callable object. When that is the case, then the remaining regular arguments and keyword arguments are passed to the callable object.
이 함수를 호출하는 두가지 방법이 있다. 첫번째 방법은 실행을 위한 Python code가 포함된 문자인수를 제공하는것이고, 이경우 제공된 코드는 해석된다. 이 routine을 호출하기위한 두번째 방법은 callable object에 이 routine을 전달하는 것이다. 이 경우 남아있는 정식인수와 약식인수는 callable object에 전달된다.

466개(20/24페이지)
마야
번호 제목 글쓴이 조회 날짜
공지 마야 뷰포트 네비게이션 팁 푸딩뱃살 42377 2020.04.06 17:22
공지 Maya 버전 별 Python 버전 푸딩뱃살 63692 2014.01.08 17:59
84 [Rendering] [스크랩] 마야 - 렌더 패스 Tutorial 사진 첨부파일 artsone 4630 2008.01.15 17:26
83 [Rendering] [스크랩] 마야 멘탈레이 - Layer Render [ Occlusion ] 사진 첨부파일 artsone 3869 2008.01.15 17:14
82 [Script] [스크랩] Maya help에 있는 Python 참조문 번역 - Current limitations artsone 4299 2008.01.15 17:07
81 [Script] [스크랩] Maya help에 있는 Python 참조문 번역 - Important difference artsone 5455 2008.01.15 17:07
80 [Script] [스크랩] Maya help에 있는 Python 참조문 번역 - Python from an exter artsone 4852 2008.01.15 17:04
>> [Script] [스크랩] Maya help에 있는 Python 참조문 번역 - Python and threading artsone 4692 2008.01.15 17:02
78 [Script] [스크랩] Maya help에 있는 Python 참조문 번역 - Using Python 사진 첨부파일 artsone 5491 2008.01.15 16:56
77 [Script] [스크랩] Maya help에 있는 Python 참조문 번역 - Python in Maya artsone 5110 2008.01.15 16:54
76 [FX] Rigid Body 테스트 사진 첨부파일 artsone 2261 2007.12.20 16:53
75 [참고] MEL Script Site artsone 2685 2007.12.17 04:31
74 [Base] 단축키 artsone 2062 2007.12.17 03:55
73 [Script] Expression - Time (sin, cos, tan) test 사진 첨부파일 artsone 2708 2007.12.15 05:40
72 [Rendering] UV Check Maps 사진 첨부파일 artsOne 1896 2007.12.09 23:45
71 [Rendering] [스크랩] V-Ray for Maya 사진 첨부파일 artsone 2631 2007.12.06 02:04
70 [Rigging] Squash and Stretch 뼈대 만들기 - IK Spline Handle 활용 사진 첨부파일 artsone 2827 2007.11.18 23:17
69 [Rigging] Squash and Stretch 뼈대 만들기 - IK Handle 활용 2 (만들기) 사진 첨부파일 artsone 2640 2007.11.16 01:14
68 [Rigging] Squash and Stretch 뼈대 만들기 - IK Handle 활용 1 (정의) 사진 첨부파일 artsOne 2509 2007.11.15 13:53
67 [Script] Expression - rad_to_deg 사진 첨부파일 artsone 2673 2007.11.14 19:40
66 [Script] Expression - time 사진 첨부파일 artsone 2320 2007.11.14 19:36
65 [Script] 리깅에 사용되는 Utility Node - Condition Node 사진 첨부파일 artsone 2235 2007.11.13 02:54