[CalendarServer-changes] [14228] twext/trunk/twext/who/opendirectory/_service.py
source_changes at macosforge.org
source_changes at macosforge.org
Wed Dec 17 12:06:03 PST 2014
Revision: 14228
http://trac.calendarserver.org//changeset/14228
Author: sagen at apple.com
Date: 2014-12-17 12:06:03 -0800 (Wed, 17 Dec 2014)
Log Message:
-----------
Refactor recordWithShortName for more code reuse, and temporarily turn off deferToThread while we investigate why the threadpool backs up.
Modified Paths:
--------------
twext/trunk/twext/who/opendirectory/_service.py
Modified: twext/trunk/twext/who/opendirectory/_service.py
===================================================================
--- twext/trunk/twext/who/opendirectory/_service.py 2014-12-12 21:25:23 UTC (rev 14227)
+++ twext/trunk/twext/who/opendirectory/_service.py 2014-12-17 20:06:03 UTC (rev 14228)
@@ -46,7 +46,7 @@
MatchExpression, MatchFlags,
)
from ..ldap._util import LDAP_QUOTING_TABLE
-from ..util import ConstantsContainer, firstResult
+from ..util import ConstantsContainer, firstResult, uniqueResult
from Foundation import NSAutoreleasePool
from ._odframework import ODSession, ODNode, ODQuery
@@ -55,7 +55,7 @@
ODSearchPath, ODRecordType, ODAttribute, ODMatchType, ODAuthMethod,
)
-DEFER_TO_THREAD = True
+DEFER_TO_THREAD = False
@@ -805,7 +805,9 @@
):
self._maybeResetPool()
+
if isinstance(expression, MatchExpression):
+ self.log.debug("OD call: {}".format(expression))
try:
query = self._queryFromMatchExpression(
expression,
@@ -844,6 +846,7 @@
self._maybeResetPool()
try:
+ self.log.debug("OD call: {}".format(expression))
query = self._queryFromCompoundExpression(
expression, recordTypes=recordTypes, limitResults=limitResults
)
@@ -983,40 +986,27 @@
@inlineCallbacks
def recordWithShortName(self, recordType, shortName, timeoutSeconds=None):
- self._maybeResetPool()
+ records = yield self.recordsFromNonCompoundExpression(
+ MatchExpression(self.fieldName.shortNames, shortName),
+ recordTypes=(recordType,),
+ limitResults=1
+ )
+
try:
- query = self._queryFromMatchExpression(
- MatchExpression(self.fieldName.shortNames, shortName),
- recordTypes=(recordType,),
- limitResults=1
+ record = uniqueResult(records)
+ except DirectoryServiceError:
+ self.log.error(
+ "Duplicate records for name: {name} ({recordType})"
+ .format(name=shortName, recordType=recordType.name)
)
- results = yield self._recordsFromQuery(
- query,
- timeoutSeconds=timeoutSeconds
- )
+ raise
- try:
- record = firstResult(results)
- except DirectoryServiceError:
- self.log.error(
- "Duplicate records for name: {name} ({recordType})"
- .format(name=shortName, recordType=recordType.name)
- )
- raise
+ returnValue(record)
- returnValue(record)
- except QueryNotSupportedError:
- # Let the superclass try
- returnValue((yield BaseDirectoryService.recordWithShortName(
- self, recordType, shortName, timeoutSeconds=timeoutSeconds)))
- except UnsupportedRecordTypeError:
- returnValue(None)
-
-
@implementer(IPlaintextPasswordVerifier, IHTTPDigestVerifier)
class DirectoryRecord(BaseDirectoryRecord):
"""
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20141217/5b3f1a5e/attachment.html>
More information about the calendarserver-changes
mailing list