| OLD | NEW |
| 1 # Copyright (c) 2006-2009 Mitch Garnaat http://garnaat.org/ | 1 # Copyright (c) 2006-2009 Mitch Garnaat http://garnaat.org/ |
| 2 # | 2 # |
| 3 # Permission is hereby granted, free of charge, to any person obtaining a | 3 # Permission is hereby granted, free of charge, to any person obtaining a |
| 4 # copy of this software and associated documentation files (the | 4 # copy of this software and associated documentation files (the |
| 5 # "Software"), to deal in the Software without restriction, including | 5 # "Software"), to deal in the Software without restriction, including |
| 6 # without limitation the rights to use, copy, modify, merge, publish, dis- | 6 # without limitation the rights to use, copy, modify, merge, publish, dis- |
| 7 # tribute, sublicense, and/or sell copies of the Software, and to permit | 7 # tribute, sublicense, and/or sell copies of the Software, and to permit |
| 8 # persons to whom the Software is furnished to do so, subject to the fol- | 8 # persons to whom the Software is furnished to do so, subject to the fol- |
| 9 # lowing conditions: | 9 # lowing conditions: |
| 10 # | 10 # |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 | 178 |
| 179 :rtype: :class:`boto.sqs.message.Message` | 179 :rtype: :class:`boto.sqs.message.Message` |
| 180 :return: A single message or None if queue is empty | 180 :return: A single message or None if queue is empty |
| 181 """ | 181 """ |
| 182 rs = self.get_messages(1, visibility_timeout) | 182 rs = self.get_messages(1, visibility_timeout) |
| 183 if len(rs) == 1: | 183 if len(rs) == 1: |
| 184 return rs[0] | 184 return rs[0] |
| 185 else: | 185 else: |
| 186 return None | 186 return None |
| 187 | 187 |
| 188 def write(self, message): | 188 def write(self, message, delay_seconds=None): |
| 189 """ | 189 """ |
| 190 Add a single message to the queue. | 190 Add a single message to the queue. |
| 191 | 191 |
| 192 :type message: Message | 192 :type message: Message |
| 193 :param message: The message to be written to the queue | 193 :param message: The message to be written to the queue |
| 194 | 194 |
| 195 :rtype: :class:`boto.sqs.message.Message` | 195 :rtype: :class:`boto.sqs.message.Message` |
| 196 :return: The :class:`boto.sqs.message.Message` object that was written. | 196 :return: The :class:`boto.sqs.message.Message` object that was written. |
| 197 """ | 197 """ |
| 198 new_msg = self.connection.send_message(self, message.get_body_encoded()) | 198 new_msg = self.connection.send_message(self, message.get_body_encoded(),
delay_seconds) |
| 199 message.id = new_msg.id | 199 message.id = new_msg.id |
| 200 message.md5 = new_msg.md5 | 200 message.md5 = new_msg.md5 |
| 201 return message | 201 return message |
| 202 | 202 |
| 203 def new_message(self, body=''): | 203 def new_message(self, body=''): |
| 204 """ | 204 """ |
| 205 Create new message of appropriate class. | 205 Create new message of appropriate class. |
| 206 | 206 |
| 207 :type body: message body | 207 :type body: message body |
| 208 :param body: The body of the newly created message (optional). | 208 :param body: The body of the newly created message (optional). |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 405 def load_from_filename(self, file_name, sep='\n'): | 405 def load_from_filename(self, file_name, sep='\n'): |
| 406 """Utility function to load messages from a local filename to a queue""" | 406 """Utility function to load messages from a local filename to a queue""" |
| 407 fp = open(file_name, 'rb') | 407 fp = open(file_name, 'rb') |
| 408 n = self.load_from_file(fp, sep) | 408 n = self.load_from_file(fp, sep) |
| 409 fp.close() | 409 fp.close() |
| 410 return n | 410 return n |
| 411 | 411 |
| 412 # for backward compatibility | 412 # for backward compatibility |
| 413 load = load_from_filename | 413 load = load_from_filename |
| 414 | 414 |
| OLD | NEW |